how to print javascript variable value in html page?

Today, We want to share with you how to print in javascript.In this post we will show you console.log javascript, hear for JavaScript: Print the contents of the current window we will give you demo and example for implement.In this post, we will learn about javascript console write with an example.

How to print to console using javascript?

  • Using InnerHTML
  • Using a Window Alert
  • Using document.write()
  • Using console.log()
  • JavaScript Print
    console.log(text);

Example 1:





javascript output

how to display javascript variable value in html page?

Using InnerHTML

index.html




    
    JavaScript innerHTML - www.pakainfo.com


    
    


Using a Window Alert

index.html





Welcome to the JavaScriptTutorial.net website!

Pakainfo.com is a good place to start.

Using Console Log

index.html









Using document.write()

index.html





Welcome to the JavaScriptTutorial.net website!

Pakainfo.com is a good place to start.

Printing from a Printer

index.html





Welcome to the JavaScriptTutorial.net website!

Pakainfo.com is a good place to start.

how to print variable in javascript?

To print a variable value in JavaScript, you can use the console.log() function. This function writes a message to the console log, which can be viewed in the browser’s developer console. Here’s how you can use console.log() to print a variable value in JavaScript:

// Declare a variable
var myVariable = 'Hello, world!';

// Print the variable value to the console log
console.log(myVariable);

In the above code, we declare a variable called myVariable and set its value to the string ‘Hello, world!’. We then use console.log() to print the value of the variable to the console log. When you run this code in a web browser and open the developer console, you will see the message ‘Hello, world!’ printed to the console log.

I hope you get an idea about javascript print function.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment