Spaces are not allowed in a variable name
Users can not use digits at the start of the variable name.
The variable names are case sensitive
It means that the uppercase and lower case are not the same it will be as separate names. An example is that let age= 12 and let Age = 13 are not the same these two are different variables because A is capital in one and is small in the other. So always take care of these things while writing your code to avoid any error.
Reserved keywords can not be used as a variable name
So using reserve words as a variable name will give this error: Uncaught SyntaxError: Unexpected token ‘this’.
Use meaningful names for variable
The name of the variable should be meaningful in such a way that it should reflect the purpose of that variable. Using meaningless names or some alphabets like x, y, a, etc will cause a problem when you face some problem after some of the development, then most programmers are not able to track the purpose of that variable in the code.
Use camel case for variable names
- Camel Case (firstWordIsSmallAndThenAllWordsFirstLetterIsCapital)
- Pascal Case (EveryWordFirstLetterIsCapital)
- Snack Case (words_are_separated_by_underscore)
As shown in the above example, in the camel case the first word is in lowercase and then the upcoming word’s first letter is capital. So try to use this in your programming.
Use uppercase for constant values
Whenever there is a constant value in your program, you have to write that variable name in an upper case like the value of Pi is constant. let PI = 3.14.