JavaScript variables are containers for storing data values.
In this example, x, y, and z are variables. Variables are declared with the let keyword.
let x = 5;
let y = 6;
let z = 11;
For the example above, you can expect:
x stores the value 5.y stores the value 6.z stores the value 11.<aside>
⚠️ Before 2015, using the var keyboard was the only way to declare a JavaScript variable.
</aside>
<aside>
⚠️ The 2015 version of JavaScript (ES6 - ECMAScript 2015) allows the use of the const keyword to define a variable that cannot be reassigned, and the let keyword to define a variable with restricted scope.
This is why this course will not be using var, but will be using let and const.
</aside>
All JavaScript variables must be identified with unique names. These unique names are called identifiers.
Identifiers can be short names (x and y) or more descriptive names (age, sum, totalVolume).
The general rules for constructing names for variables (unique identifiers) are: