You will learn the meaning of identifiers and basic rules. It's good to know before you start to learn variables.
What are identifiers
An identifier is a symbol that represents, names a piece of data. An identifier can represent a function or a variable, for example. There are some rules regarding the identifiers.
We settled that identifiers are names that represent pieces of data. You name your own identifiers, in fact that’s the most important thing regarding identifiers. But you must respect some rules when you name your own variables:
Your identifiers must start with a letter, or with the underscore sign “_”. You cannot start an identifier with a digit, or with some other sign like $, %, @, etc. But after the first character in your identifier, you can use digits to build your identifier name.
You cannot use space in your identifiers. If you must specify two or more words in an identifier, you can use the underscore sign or capitalize the second word, like this:
It's easier to read than:
The following examples of identifiers are correct:
MyVar Var1 Total_Price _ConstPrice X
And the following are incorrect:
1stVar total price $Price
Therefore be very careful when you choose your identifier name, if you break the rules, the browser will most probably throw a hard to debug error. There is one more thing you must be aware of ‘ the reserved identifiers.
This is the list of reserved words: