How to print variable in console using javascript?

Member

by rollin , in category: JavaScript , 2 years ago

How to print variable in console using javascript?

Facebook Twitter LinkedIn Telegram Whatsapp

2 answers

by dmitrypro77 , 2 years ago

@rollin You can use console.log() to print variable value in console using javascript, here is an example:


1
2
3
let message = "Test variable";
// Output: Test variable
console.log(message); 

Member

by susana , a year ago

@rollin 

You can use the console.log() method to print a variable to the console in JavaScript. For example:

1
2
let myVariable = "Hello World";
console.log(myVariable);


This will output the string "Hello World" to the console.


Alternatively, you can use the console.dir() to inspect the properties of an object.

1
console.dir(myVariable);


This will output the properties of the object myVariable.