You use symbolic variables to hold data in your application. You give these variables names by which you reference them, and there are certain rules to which the names must conform. You use literals for specific, fixed numbers, strings, and boolean values in scripts.
A JavaScript identifier or name must start with a letter or underscore ("_"); subsequent characters can also be digits (0-9). Letters include the characters "A" through "Z" (upper case) and the characters "a" through "z" (lower case). Names in server-based JavaScript are case-sensitive. Client JavaScript is not case-sensitive.
Some examples of legal names are:
Number_hits
temp99
_name
Literals are the basic representation of any integer, floating point, boolean, or string value. These are fixed values that you literally provide in your application source, and are not variables. Examples of literals include
42
3.14159
"To be or not to be"
Integers can be expressed in decimal (base 10), hexadecimal (base 16), or octal (base 8) format. A decimal integer literal consists of a sequence of digits (optionally suffixed as described below) without a leading 0 (zero).
An integer can be expressed in octal or hexadecimal rather than decimal. A leading 0 (zero) on an integer literal means it is in octal; a leading 0x (or 0X) means hexadecimal. Hexadecimal integers can include digits (0-9) and the letters a-f and A-F. Octal integers can include only the digits 0-7.
A floating point literal can have the following parts: a decimal integer, a decimal point ("."), a fraction (another decimal number), an exponent, and a type suffix. The exponent part is an "e" or "E" followed by an integer, which can be signed (preceded by a "+" or "-"). A floating point literal must have at least one digit, plus either a decimal point or "e" (or "E"). Some examples of floating point literals are:
The boolean type has two literal values: true and false.
A string literal is zero or more characters enclosed in double (") or single (') quotes. A string must be delimited by quotes of the same type; that is, either both single quotes or double quotes. The following are examples of string literals:
"blah"
'blah'
"1234"
"one line \n another line"
You can use the following special characters in JavaScript string literals: