Image about your birthday and how business operates around your birthday, gifts are ordered from online shops like amazon and flipkart. Variables store data that can be set, updated, and retrieved whenever needed.
var num = 1; //{1}
num = 3; //{2}
var price = 1.5; //{3}
var name = 'Packet of Milk'; //{4}
var trueValue = true; //{5}
var nullVar = null; //{6}
const gift="Friends are the best gift."
Let's start with a story, you blow the candle and after the celebration is done, you pick up the gifts and keep them into the place /table or box. This table/(box) or place is a memory location and A variable is a container for storing valuies.
Keep in mind ,variable=vari+able, which is changeable or not fix. whatever value you place in a variable that can vary over time.
var chai=150;
we created a chai which is 150 rupees and there we are dealing with variable declaration and assignment in one line.
let chai=150;
we created a variable chai with same price 150 and now let's try to observe ,what is the difference.
IF We want that our chai price will be fix and not change over the time, we will Harness the fix price.
const chai=250;
here we have fixed the chai price.
In js,we have available types --numbers,strings, Booleans, functions, and objects.
what is the scope?
Scope is the set of rules for variable ,where it is visible function, block or full file (global).



Top comments (0)