Variable In JavaScript With Example


JavaScript uses varĀ  Keyword to declare a variable.

var <variable-name>;

var <variable-name> = <value>;


var one = 1; 

var two = 'two';  

Rules of Naming Variable :

  • The first character must be a letter or an underscore (-) or an dollar($). You can not use a number as the first character.
  • . The variable name can include any letter, any number, or the underscore. Can’t use any other characters, including spaces.
  • Variable names are case sensitive
  • No limit to the length of the variable name.

Leave a Comment