JavaScript Variables
Variables
Variables are containers for storing value. Their value can be changed over time.
Declaring Variable in JavaScript:-
We can easily declare a variable by using var.
Example:-
var x = 10;
In this, we assign x the value of 10. The "=" sign is called the assignment operator.
Naming rules for JavaScript variables are:-
- The first character of a variable name must be a letter, underscore (_), or a dollar sign ($).
- The first character of a variable name can’t be a number.
- Variable names can’t include a mathematical or logical operator in their name.
- Variable names can’t contain spaces.
- Variable names can't allow special symbols