Variables can be thought of as named containers.
In this precedent, x, y, and z, are variables:
var y = 7;
var z = x + y;
From the precedent above, you can expect:
- x stores the esteem 8
- y stores the esteem 7
- z stores the esteem 15
Much Like Algebra
In this precedent, item1, item2, and complete, are variables:
var item2 = 7;
var all out = itme1 + item2;
In programming, much the same as in polynomial math, we use factors (like price1) to hold values.
In programming, much the same as in polynomial math, we use factors in articulations (complete = price1 + price2).
From the precedent above, you can ascertain the aggregate to be 11.
These remarkable names are called identifiers.
Identifiers can be short names (like x and y), or increasingly graphic names (age, entirety, totalVolume).
The general principles for building names for factors (remarkable identifiers) are:
- Names can contain letters, digits, underscores, and dollar signs.
- Names must start with a letter
- Names can likewise start with $ and _ (however we won't utilize it in this tutorial)
- Names are case delicate (y and Y are distinctive variables)
The Assignment Operator
This is not the same as variable based math. The accompanying does not bode well in algebra:
In programming, content qualities are called content strings.
Strings are composed inside twofold or single statements. Numbers are composed without quotes.
If you put statements around a number, it will be treated as a content string.
var individual = "Sophie";
var answer = 'Yes I am!';