No icon

JAVASCRIPT VARIABLES

JAVASCRIPT VARIABLES

JAVASCRIPT VARIABLES TYPES 

There are three types of javascript Variables 

1. VAR

 Var type is used to define one value to one variable 

Example : var y=10;

above example output i.e value of y will be 10; 

But disadvantage with vartype variable is that if you again redefine that varible with another value previous value will be erased and new value stored in that variable.

THREE RULES TO DEFINE VAR TYPE 

1. variable name start with

           _ $ , a-z , A-Z

2. Variables after first letter may be any of these flow

          _ $ , a-z , A-Z , 0-9 but in between variable's don't use - like any.

3. we can specify multiple variables in a single line 

Example:  var a=10, b=20;

2. LET

Once variable is defined , we can't assign new values to that variable it throughs error like variable already defibned.

3.CONSTANT

once variabe value defined unchangable.

Comment As:

Comment (0)