To display the variable var
, which contains the value 1, to the console in JavaScript, you would use the console.log()
method. Here's how you could do it:
let var = 1; // Note: 'var' is a reserved keyword, so it's better to choose a different name
console.log(var);
However, it's important to note that var
is a reserved keyword in JavaScript used for variable declarations. Therefore, you should avoid using var
as a variable name. Instead, you could name the variable something like myVar
:
let myVar = 1;
console.log(myVar);
This will correctly display the value 1
in the console.