What is the correct syntax for declaring a variable in JavaScript?

  • var myVariable = 10;
  • let myVariable = 10;
  • const myVariable = 10;
  • myVariable = 10;
In JavaScript, variables can be declared using the var, let, or const keywords. Option 2 shows the correct syntax using the let keyword, which is commonly used for variable declaration in modern JavaScript.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *