Please note that index links point to page beginnings from the print edition. Locations are approximate in e-readers, and you may need to page down one or more times after clicking a link to get to the indexed material.
A
<a> tags, 143
abs( ) function, 27
accessing
arguments, 113–114
Document Object Model, 144–150
objects, 124–125
acos( ) function, 27
addition
arithmetic operator, 24
assignment operator, 28
Ajax
ajax.htm, 194
ajax.php, 195–196
ajax2.htm, 196–198
callback( ), 193
creating objects, 189–191
GetAjaxRequest( ), 192–193
OnDOMReady( ), 198–200
PostAjaxRequest( ), 191–192
security, 198
ajax.htm document, 194
ajax.php program, 195–196
ajax2.htm document, 196–198
alert( ) function, 130, 170, 180
ampersands (&)
″and″ bitwise operator, 35
″and″ logical operator, 34
″and″ operator
bitwise, 35
logical, 34
Android browser, 173
angle brackets (<>) for regular expressions, 136–137
animations
description, 7
interrupts example, 183–185
anonymous arguments, 111–112
anonymous functions, 117–118, 124
appendChild( ) function, 158
arguments, 111–112
accessing, 113–114
passing, 112–113
arguments object, 114–116
arithmetic functions, 27–28, 221
arithmetic operators, 23–25
arrays, 41–42
accessing, 59–60
assigning values to, 43
concat( ), 62–64
for( ), 61–62
forEach( ), 65
functions, 222–223
inserting elements into, 86
join( ), 64–65
map( ), 66
multidimensional. See multidimensional arrays
names, 42
pop( ), 73–75
push( ), 71–75
removing elements from, 85
retrieving values from, 44
reverse( ), 75–76
sorting, 81–84
splice( ), 84–87
stacks and buffers, 76–79
strings from, 64–65
asin( ) function, 27
assigning values to arrays, 43
assignment operators, 28–29
associative arrays
creating, 46–47
description, 6
multidimensional, 56–57
associativity of operators, 37–38
assignment operators, 28
character matching, 136–137
comments, 12
fuzzy matching, 135–136
multiplication, 24
atan( ) function, 27
atan2( ) function, 27
audio
description, 7
HTML5, 160–163
automatic type casting, 20
availHeight property, 152–153
B
B metacharacter, 138
metacharacter, 138
back( ) method, 152–153
backslashes ()
escaping characters, 19
regular expressions, 136
bitwise operators, 35
body
code in, 13–14
Document Object Model, 141–143
Boolean( ) function, 21
Boolean functions, 223
Boolean values for if( ) constructs, 89
braces ({})
arguments, 112
if( ), 89–91
regular expressions, 138
brackets ([])
multidimensional arrays, 53
regular expressions, 136–137
break keyword
loops, 107–108
switch( ) statements, 96
browsers
differences between, 173–174
query strings, 176–178
user agent string, 174–175
buffers, arrays for, 76–79
bugs, 129
ignoring, 132–133
onerror events, 129–131
try catch( ) structures for, 131–132
C
C( ) function, 148–149
callback( ) function, 191, 193
canceling
interrupt intervals, 183
timeouts, 181–182
canvas, 7
carets (^)
bitwise operator, 35
regular expressions, 136–137
carriage return characters, 16
case sensitivity
regular expressions, 134–136
variables, 15
case statements, 95–96
casting variables, 20–21
ceil( ) function, 27
character matching in regular expressions, 136
classes. See also objects
CSS, 148
declaring, 123–125
extending, 127
clearInterval( ) function, 183
closed property, 152
code, placing, 13–15
colons (:)
arrays, 47
switch( ) statements, 96
ternary operator, 35
colorDepth property, 152–153
commas (,)
arguments, 112
for( ) loops, 105
join( ), 65
comments, 11–12
comparison operators, 31–33
concat( ) function, 62–64
concatenation
arrays, 62–64
strings, 20
constructors, 124
continue statement, 108–110
controls attribute, 161
cookies
deleting, 168–169
overview, 165–166
reading, 167–168
setting, 166–167
cos( ) function, 27
CreateAjaxObject( ) function, 189–191
createElement( ) function, 158
cross-browser attacks, 198
curly braces ({})
arguments, 112
if( ), 89–91
regular expressions, 138
D metacharacter, 138
d metacharacter, 138
date functions, 223–225
declaring classes, 123–125
decodeURIComponent( ) function, 177–178
decrement operator, 24–27
default keyword in switch( ) statements, 96–97
defaultStatus property, 152–153
DeleteCookie( ) function, 168–169
deleting
cookies, 168–169
local storage items, 171
division
arithmetic operator, 24
assignment operator, 28
modulus operator, 23–24
operator precedence, 36
do while( ) loops, 103–105
document body, code in, 13–14
document head, code in, 13
Document Object Model (DOM), 6, 141
accessing, 144–150
adding elements, 157–159
C( ), 148–149
classes, 148
example, 141–144
function summary, 149–150, 225
getElementById( ), 144–145
O( ), 146–147
properties, 148–151
removing elements, 159
S( ), 147–148
document property, 152
dollar signs ($) in regular expressions, 137
domains for cookies, 166–167
dots (.)
properties, 6
regular expressions, 136–137
double-quotation marks (″)
strings, 18–19
whitespace, 15
dynamic elements, 7
E
ECMA (European Computer Manufacturers Association), 4
ECMAScript standard, 4
Eich, Brendan, 4
else statement, 91–93
else if( ) statement, 93
empty strings, 19
encodeURI( ) function, 166
″equal to″ comparisons, 32–33
equals signs (=)
arrays, 47
assignment operators, 28
bitwise operators, 35
comparison operator, 32–33
errors, 129
ignoring, 132–133
onerror events, 129–131
try catch( ) structures for, 131–132
escaping characters
overview, 19
query strings, 176
European Computer Manufacturers Association (ECMA), 4
events in inline JavaScript, 157–158
exclamation points (!)
comparison operator, 33
″not″ logical operator, 34
exp( ) function, 27
expressions. See regular expressions
extending functions, 126–127
F
fall-through in switch( ) statements, 97–98
false value, 21
comparison operator, 32–33
logical operators, 34
file_get_contents( ) function, 195
files, including, 14–15
FILO (First In/Last Out) arrays, 76
Firefox, 173
floating elements, 7
floor( ) function, 27–28
for( ) loops, 105–106
for (in) loops, 61–62, 106–107
forEach( ) function, 65
form processing, 7
form tags, 143
forward( ) method, 153
frames property, 152
functions, 6
accessing arguments, 113–114
arguments object, 114–116
Boolean, 223
dates, 223–225
DOM, 225
extending, 126–127
global, 226
global naming convention, 121
names, 15
number, 226–227
passing arguments, 112–113
regular expressions, 227
return keyword, 112
strings, 227–228
this( ) keyword, 116–117
variable scope, 118–121
windows, 228
working with, 111–112
G
gaming, 7–8
geolocation, 7
GetAjaxRequest( ) function, 192–193
GetBrowser( ) function, 174–175
GetCookie( ) function, 167–168
getElementById( ) function, 144–145
getItem( ) function, 169
GetQueryString( ) function, 176–177
global functions, 226
global naming convention, 121
global replacements, regular expressions for, 135
Gmail, 8–9
go( ) method, 153
Google Chrome, 173
greater than signs (>)
bitwise operator, 35
comparison operator, 33
regular expressions, 136
H
hash tables for associative arrays, 46
head
code in, 13
Document Object Model, 141–143
history object, 153
hover effects, 7
HTML5 media, 160–163
HyperText Transfer Protocol (HTTP), 3
I
if( ) construct, 89
braces, 90–91
else, 91–93
else if( ), 93
logical operators, 34
<img> tags, 143
in-browser gaming, 7–8
in-browser scripting, 5–6
including files, 14–15
increment operator, 24–26
indentation in if( ) constructs, 90
indexes
arguments object, 115
for (in), 62
forEach( ), 65
indexOf( ) function, 175
Info( ) function, 65
inline JavaScript, 155–156
adding elements, 157–159
events, 157–158
HTML5 media, 160–163
object visibility, 159–160
removing elements, 159
this keyword, 156
innerHeight property, 152–153
innerHTML property, 186, 193, 196
innerWidth property, 152–153
<input> tags, 143
inserting elements into arrays, 86
instances for objects, 124
interactivity. See inline JavaScript
Internet Explorer (IE), 5, 173
interrupts
animation example, 183–185
intervals, 182–183
overview, 179–182
intervals for interrupts, 182–183
iOS browser, 173
J
join( ) function
arguments, 113–114
arrays, 64–65
.js extension, 14
JScript, 5
K
keys for associative arrays, 46
L
Last In/First Out (LIFO) arrays, 76
lazy evaluation, 37
left-shift operators, 35
left-to-right associativity, 37–38
length property, 152
less than signs (<)
bitwise operator, 35
comparison operator, 33
regular expressions, 136
LIFO (Last In/First Out) arrays, 76
LiveScript browser, 4
local storage, 169–171
local variables, 118–121
location property, 152
log( ) function, 27
logical operators, 33–34
logical_operators.htm file, 34
loops, 101
breaking out of, 107–108
continue statement, 108–110
do while( ), 103–105
for( ), 105–106
for (.in.), 106–107
while( ), 101–103
M
map( ) function, 66
Math library functions, 27–28
max( ) function, 27
media, HTML5, 160–163
memory, prototype keyword for, 125–127
meta tags, 143
metacharacters in fuzzy matching, 135–138
methods, 124
min( ) function, 27
minus signs (-)
assignment operators, 28
decrement operator, 24–27
operator precedence, 37
regular expressions, 137
subtraction, 24
Mocha browser, 4
modulus operator (%)
assignment operators, 28
description, 23–24
Mosaic web browser, 173
Mozilla Firefox, 173
multidimensional arrays, 49–50
associative, 56–57
creating, 57–59
example, 54–56
two-dimensional, 50–54
multiline comments, 12
multiplication
arithmetic operator, 24
assignment operators, 28
operator precedence, 36
N
metacharacter, 138
name property, 152
named arguments, 111–112
names
arrays, 42
case sensitivity, 15
cookies, 166–167
global naming convention, 121
variables, 17
NaN value, 21
NavCheck( ) function, 175
navigator property, 152
Netscape Navigator browser, 4, 173
newline characters, 16
″not″ operator
bitwise, 35
logical, 34
Number( ) function, 20–21
number functions, 226–227
numeric variables, 17
numerical sorting for arrays, 82–83
O
O( ) function
Document Object Model, 146–147
HTML5, 162
objects, 123. See also classes
accessing, 124–125
Ajax, 189–191
creating, 124
overview, 6–7
prototype keyword, 125–127
visibility, 159–160
on events, 158–159
OnDOMReady( ) function, 198–200
onerror events, 129–131
opacity property, 160
opener property, 152
Opera browser, 173
operators
arithmetic, 23–25
assignment, 28–29
associativity, 37–38
bitwise, 35
comparison, 31–33
logical, 33–34
precedence, 35–37
ternary, 35
″or″ operator
bitwise, 35
logical, 34
outerHeight property, 152
outerWidth property, 152
P
pageXOffset property, 152
pageYOffset property, 152
parent property, 152
parentheses ( )
arguments, 112
functions, 6
operator precedence, 36
regular expressions, 137
passing arguments, 112–113
passing by reference, 125–126
passwords in cookies, 169
paths for cookies, 166–167
pause( ) function, 162–163
percent signs (%)
assignment operators, 28
modulus operator, 23–24
periods (.)
properties, 6
regular expressions, 136–137
pixelDepth property, 152–153
placing code, 13–15
play( ) function, 162–163
plus signs (+)
addition, 24
assignment operators, 28
increment operator, 24–26
operator precedence, 37
query strings, 176
regular expressions, 136–137
position property, 160
post-incrementing and decrementing operations, 24–27
PostAjaxRequest( ) function, 191–192
postMessage( ) function, 186
pow( ) function, 27
pre-incrementing and decrementing operations, 25–27
precedence for operators, 35–37
program flow, 89
if( ) constructs, 89–94
loops, 101–110
switch( ) statements, 94–98
properties
CSS and JavaScript, 148–149
Document Object Model, 141, 148–151
prototype keyword, 116, 125–127
push( ) function, 71–75
PushToTop( ) function, 78–79
Q
query strings
browsers, 176–178
Document Object Model, 143
question marks (?)
query strings, 176
regular expressions, 137
ternary operator, 35
quotation marks (″)
strings, 18–19
whitespace, 15
R
random( ) function, 27–28
reading cookies, 167–168
recursion, 74–75
regular expressions, 133
character matching, 136
functions, 227
fuzzy matching, 135–136
global replacements, 135
replace( ), 134–135
test( ), 133–134
removeChild( ) method, 159
removeItem( ) function, 169, 171
removing
array elements, 85
DOM elements, 159
repeating timeouts, 181
replace( ) function, 134–135
retrieving values from arrays, 44
return keyword for functions, 112
reverse( ) function, 75–76, 84
right-shift operators, 35
right-to-left associativity, 37–38
round( ) function, 27
S
S metacharacter, 138
s metacharacter, 138
Safari browser, 173
scope
onerror events, 131
variables, 118–121
screen property, 152
screenLeft property, 152
screenTop property, 152
<script> tag, 14–15
scripting, in-browser, 5–6
seconds setting for cookies, 166–167
security
Ajax, 198
cookies, 166–167
self property, 152
semicolons (;)
cookies, 167
for( ) loops, 105
setAttribute( ) function, 149–150
SetCookie( ) function, 166–167
setInterval( ) function, 182–183
setItem( ) function, 169–170
setTimeout( ) function, 180–181
shift( ) function, 78–79
shift operators, 35
showTime( ) function, 182–183
sin( ) function, 27
size of arrays, 41
slashes (/)
assignment operators, 28
comments, 12
division, 24
sort( ) function, 81–82
SortNumeric( ) function, 83
spaces in query strings, 176
splice( ) function, 84–87
split( ) function, 130
sqrt( ) function, 27
square brackets ([])
multidimensional arrays, 53
regular expressions, 136–137
stacks, arrays for, 76–79
static methods, 126
status property, 152–153
storage, local, 169–171
String( ) function, 21
strings
from arrays, 64–65
concatenating, 20
functions, 227–228
splitting, 130
timeouts, 181
variables, 17–18
subtraction
arithmetic operator, 24
assignment operators, 28
switch( ) statements, 94–96
break keyword, 96
default keyword, 96–97
fall-through, 97–98
syntax, 15
T
metacharacter, 138
tab( ) function, 27
ternary operator, 35
test( ) function, 133–134
this keyword, 7
constructors, 124
inline JavaScript, 156
working with, 116–117
tildes (~) for bitwise operator, 35
timeouts
canceling, 181–182
repeating, 181
setting, 180–181
top property, 152
toTimeString( ) function, 182
true value, 21
comparison operator, 32–33
logical operators, 34
try.catch( ) structures, 131–132
two-dimensional arrays
accessing, 52–54
creating, 50–52
typing variables, 19–20
U
undefined value, 113
unescape( ) function, 178
unshift( ) function, 78–79
URLs
onerror events, 130
user agent string for browsers, 174–175
V
values
assigning to arrays, 43
associative arrays, 46
cookies, 166–167
retrieving from arrays, 44
variables, 16–17
casting, 20–21
names, 17
scope, 118–121
string, 17–18
typing, 19–20
vertical bars (|)
″or″ bitwise operator, 35
″or″ logical operator, 34
regular expressions, 137
video
description, 7
HTML5, 160
visibility of objects, 159–160
visibility property, 159
W
W metacharacter, 138
w metacharacter, 138
web workers, 185–187
while( ) loops, 101–103
window property, 153
windows functions, 228
with keyword, 38
X
x metacharacter, 138
18.188.96.5