0% found this document useful (0 votes)
8 views12 pages

Class 2) Variables in Java Script

The document explains the concept of variables in JavaScript, defining them as names for memory locations used to store data. It outlines four ways to declare variables: automatically, using var, let, and const, with notes on the historical context and usage of each keyword. Additionally, it highlights the differences in re-declaration and mutability between var, let, and const.

Uploaded by

rajkumarleka1708
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views12 pages

Class 2) Variables in Java Script

The document explains the concept of variables in JavaScript, defining them as names for memory locations used to store data. It outlines four ways to declare variables: automatically, using var, let, and const, with notes on the historical context and usage of each keyword. Additionally, it highlights the differences in re-declaration and mutability between var, let, and const.

Uploaded by

rajkumarleka1708
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like