Storing values with operators (in short)
Storing Values with the Assignment Operator
In JavaScript, you can store a value in a variable with the assignment operator (=
).
myVariable = 5;
This assigns the Number
value 5
to myVariable
.
If there are any calculations to the right of the =
operator, those are performed before the value is assigned to the variable on the left of the operator.
var myVar;
myVar = 5;
First, this code creates a variable named myVar
. Then, the code assigns 5
to myVar
. Now, if myVar
appears again in the code, the program will treat it as if it is 5
.
Assign the value 7
to variable a
.
Hope I was able to create this point to you, if you have still doubts related to this then please comment me I will try to reply as soon as possible...
Thanks for reading...!