MAGIZHCHI SOFTWARE
VARIABLES IN JAVA SCRIPT
What is Variable ?
Variable is a name given to the Memory location in Ram.
Or, variable is the name of the Container For Storing Data
In java Script variable is declared in 4 Ways
01 Automatically
02 Using var
03 Using let
05 04 Using const
Automatically variable
05
Note :
01 The var keyword was used in all JavaScript code from 1995 to 2015.
02 The let and const keywords were added to JavaScript in 2015.
03 The var keyword should only be used in code written for older browsers.
04 var re-declaration of variables within the same function or global scope.
var c = 1;
var c = 2; // OK, re-declaration is allowed
05 [Link](c); // Output: 2
Using var variable
05
Output
05
Using let variable
Let not allow re-declaration of variables within the same block.
05
Output
05
Using const variable
If any variable declared as const the value cannot be modified
(like final keyword in java)
05
Output
05