It is important to remember that JavaScript is case sensitive, which means that as far as JavaScript is concerned the lower case a is different from the upper case A. For example the following code will produce a JavaScript error:
var Value = 5; document.write(value);
The error message will say: value is undefined. The reason for this is as far a JavaScript is concerned Value and value are two separate identifiers (variables).
Variables..one more thing.
A JavaScript identifier (variable) cannot be a JavaScript reserved word.
JavaScript reserved words are the commands used by JavaScript to create JavaScript programs.
So is that everything we need to know about variables?
JavaScript Reserved Words...
Here are the JavaScript reserved words:
abstract boolean break byte case catch char class const continue default delete do double else extends false final finally float for function goto if implements import in instance of int interface long native new null package private protected public return short static super switch synchronized this throw throws transient true try type of var void while with
As an example:
var function = 4;
would produce a JavaScript error because function is a JavaScript reserved word.
A Little Exercise...
See if you can find which of the following are legal identifiers in JavaScript (answers on the next page):
A] var One; B] var 2value; C] var This One; D] var My_function; E] var super;