HTML and CSS Reference
In-Depth Information
Floating-point numbers are fractional numbers such as 123.56 or -2.5. They must
contain a decimal point or an exponent specifier, such as 1.3e-2. The letter “ e ” for expo-
nent notation can be either uppercase or lowercase.
JavaScript numbers can be very large (e.g., 10 308 or 10 - 308 ).
EXAMPLE 3.1
integer
12345
float
23.45
scientific notation
.234E-2
scientific notation
.234e+3
hexadecimal
0x456fff
hexadecimal
0x456FFF
octal
0777
String Literals and Quoting. String literals are rows of characters enclosed in either
double or single quotes. 1 The quotes must be matched. If the string starts with a single
quote, it must end with a matching single quote, and likewise if it starts with a double
quote, it must end with a double quote. Single quotes can hide double quotes, and dou-
ble quotes can hide single quotes:
"This is a string"
'This is another string'
"This is also 'a string' "
'This is "a string"'
An empty set of quotes is called the null string. If a number is enclosed in quotes, it
is considered a string; for example, “5” is a string, whereas 5 is a number.
Strings are called constants or literals. The string value “hello” is called a string con-
stant or literal. To change a string requires replacing it with another string.
Strings can contain escape sequences (a single character preceded with a backslash),
as shown in Table 3.1. Escape sequences are a mechanism for quoting a single character.
Table 3.1 Escape Sequences
Escape Sequence
What It Represents
\'
Single quotation mark
\"
Double quotation mark
\t
Tab
1. Any string without quotation marks surrounding it is considered the name of a variable.
 
Search WWH ::




Custom Search