Variable In JavaScript With Example

Advertisement

JavaScript uses varĀ  Keyword to declare a variable.

Syntax:
var <variable-name>;

var <variable-name> = <value>;

Example:-

var one = 1; 

var two = 'two';  

Rules of Naming Variable :

Advertisement
  • 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