HTML and CSS Reference
Table G-4 Valid and Invalid Variable Names
Valid Variable Names
Invalid Variable Names
Cust id number
Variables are declared the first time they are used by inserting the word var , then
the variable name, followed by an equal sign (5), and then the value. For example, if you
declare a variable named gpa by typing var gpa , this variable would be assigned no value.
To assign a variable an initial value of zero, type var gpa 5 0 . Current versions of Mozilla
Firefox and Microsoft Internet Explorer indicate that a variable is undefined if the variable
has not been assigned a value. In addition, a variable can have a null value.
While a variable is used to store data or values, a literal is a constant value that does not
change. A literal is an actual number or text, rather than a calculated result or value input
from a keyboard. If the literal is a number, it is called a numeric literal; if it is a character
or text value, it is called a string literal.
A string literal is text enclosed in quotation marks. With string literals, you must
place the text inside a pair of quotation marks. If numeric digits are enclosed within
quotation marks, they will be treated as a string, not as a number. Think of the characters
between quotation marks as a sequential group of characters, one after the other, forming
a continuous string.
Escape Sequences in Strings
The escape character (\) indicates that the character that follows in a string has a special
meaning. The escape character and its following character form an escape sequence .
The escape sequences are summarized in Table G-5.
Table G-5 Escape Sequences
Apostrophe or single
Double quotation mark
where d is a digit