HTML and CSS Reference
In-Depth Information
Table G-4 Valid and Invalid Variable Names
Valid Variable Names
Invalid Variable Names
cust_id
cust.id
Cust_Id
%Cust_Id
_cust_id
1 1cust_identifier
cust_id_number
Cust id number
CustIdNumber
9custIDNumber
Custid1
Cust ID
_case
case
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.
Literals
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
Escape Sequence
Meaning
Escape Sequence
Meaning
\'
Apostrophe or single
quotation mark
\r
Carriage return
\"
Double quotation mark
\t
Horizontal tab
\\
Backslash
\v
vertical tab
\b
Backspace
\ ddd
Octal sequence
(deprecated)
\f
Form feed
\x dd
Hexadecimal sequence
\n
New line
\u dddd
Unicode sequence
where d is a digit
Search WWH ::




Custom Search