JavaScript Variables

1 min read
Variables are containers for storing data in JavaScript.
JavaScript Variables can be declared in 4 ways:
Automatically
Using var
Using let
Using const
Automatically
They are automatically declared when first used:
x = 5;
y = 10;
z = x + y;
Using
var
The var keyword was used in all JavaScript code with the old browser.
Example:
var carName
Using
let
It is used only if you can’t use
const
Example:
let carName = “volvo”;
Using
const
It is used if the data type is not changing i.e (Arrays and Objects)
0
Subscribe to my newsletter
Read articles from James Alosi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
