Index
@ alias, 51–52
=> (fat arrow), 154–156
(back slashes),
/ (forward slashes), 76
A
adding
compilers to browsers, –
form to client-side todo list application, 242–247
jQuery to client-side todo list application, 240–241
views to todo list application, 268–273
aliases, 46–47
@ alias, 51–52
and alias, 49–50
Boolean aliases, 50–51
not alias, 48–49
or alias, 49–50
and alias, 49–50
anonymous wrapper function, 20–22
APIs, writing todo API, 225–226
app server
building with Node.js, 199–213
testing with Node.js, 214–215
arguments, 70–72
default arguments, 72–75
splats, 75–79
arithmetic operators, 33–35
arrays, 81–90
destructing assignment, 86–90
iterating, 105–106
slicing, 92–94
swapping assignment, 85–86
testing inclusion, 83–84
values
injecting, 95–96
replacing, 94–95
Ashkenas, Jeremy, 255
assignment operators, 35–39
asynchronous programming, 151–154
attributes, retrieving from objects, 101–103
B
back slashes (),
Backbone, 255–256
configuring for todo list application, 256–259
todo model, writing, 256–259
todos
creating, 265–268
listing with view, 263–265
bare flag, –10
beforeEach function, 181–187
binding, 151–158
block comments, 30
Boolean aliases, 50–51
Bootstrap, building client-side todo list application, 237–240
browsers, in-browser compilation, –
build task (Cake), 167
building
objects, 96–101
todo list application
client-side, 237–252
controller, cleaning up, 232–236
Express, setting up, 218–222
MongoDB, setting up, 222–225
server-side, 217
todo API, writing, 225–226
by keyword, 106–107
C
Cake, 161
tasks
invoking, 167–169
options, 163–167
running, 163
writing, 162–163
Cakefiles, 161
calling functions, 68–70
classes
defining, 123–124
extending, 137–145
inheritance, 137–145
scope, 127–137
class-level functions, 145–150
clean task (Cake), 167
cleaning up todo list application controller, 232–236
client-side todo list application, building, 237–252
closing REPL,
code, not repeating, 68
coffee command, –
CoffeeScript, declaring variables, 19–20
collections
arrays
destructing assignment, 86–90
injecting values, 95–96
iterating, 105–106
replacing values, 94–95
slicing, 92–94
swapping assignment, 85–86
testing inclusion, 83–84
ranges, reverse ranges, 91–92
command-line compilation, –
comments, 29–30
block comments, 30
inline comments, 29–30
comparison operators, 39–42
compile flag, –
compiling
command-line compilation, –
in-browser compilation, –
comprehensions, 116–118
concatenation, forward slashes (/), 76
conditional statements
if statement, 53–54
if/else if statement, 56–58
if/else statement, 54–56
inline conditionals, 60
switch case statements, 60–63
unless statement, 58–60
configuring
Backbone for todo list application, 256–259
Jasmine, 172–175
constructor function, 126–127
creating objects, 96–101
custom matchers (Jasmine), defining, 187–190
D
declaring variables
in CoffeeScript, 19–20
in JavaScript, 18–19
default arguments, 72–75
defining
Cake tasks, 162–163
classes, 123–124
functions, 68–70
arguments, 70–72
default arguments, 72–75
parentheses, 72
matchers (Jasmine), 187–190
regular expressions, 31
deleting
models from views (todo list application), 273–274
todos in client-side todo list application, 252
“describe” block (Jasmine), writing, 175
destructing assignment, 86–90
do keyword, 119–120
dot notation, 101
E
executing CoffeeScript files, 11
existential operator, 43–46
Express, building todo list application, 218–222
extended regular expressions, 31
extending classes, 137–145
F
fat arrow (=>), 154–156
flags
bare flag, –10
compile flag, –
output flag,
print flag, 10
watch flag, 10–11
for loops
by keyword, 106–107
when keyword, 107, 109–110
form, adding to client-side todo list application, 242–247
function keyword, 16
functions, 65–68
anonymous wrapper function, 20–22
arguments, 70–72
default arguments, 72–75
splats, 75–79
beforeEach, 181–187
binding, 151–158
class-level, 145–150
constructor, 126–127
defining, 68–70, 125–126
overriding, 142–145
prototype functions, 110, 150–151
G-H
Hello World program, Node.js, 195–197
heredocs, 28–29
HTML files in-browser compilation, –
I
if statement, 53–54
if/else if statement, 56–58
if/else statement, 54–56
in-browser compilation, –
inheritance, 137–145
injecting array values, 95–96
inline comments, 29–30
inline conditionals, 60
installing
Jasmine, 172
Node.js, 194–195
interpolation, string interpolation, 23–25
iterating arrays, 105–106
J-K
Jasmine
“describe” block, writing, 175
installing, 172
matchers, defining, 187–190
setting up, 172–175
testing with, 175–176
beforeEach function, 181–187
unit testing, 176–181
JavaScript
Backbone, 255–256
todo model, writing, 256–259
todos, listing with a view, 263–265
Node.js, 193–194
app server, building, 199–213
app server, testing, 214–215
Hello World program, 195–197
installing, 194–195
streaming APIs, writing, 197–199
variables, declaring, 18–19
jQuery, adding to client-side todo list application, 240–241
keywords, var, 19
L
listing existing todos in todo list application, 247–248
literal strings, 25–28
long options, 163
loops
comprehensions, 116–118
do keyword, 119–120
for loops
by keyword, 106–107
when keyword, 107, 109–110
until loops, 114–115
while loops, 113–114
M-N
MongoDB, setting up, 222–225
Mongoose, finding todos in todo list application, 227–228
new keyword, 124
Node.js, 193–194
app server
building, 199–213
testing, 214–215
Hello World program, 195–197
installing, 194–195
streaming APIs, writing, 197–199
NPM (Node Package Management), 193
Express, setting up, 218–222
O
objects
attributes, retrieving, 101–103
building, 96–101
destructing assignment, 103–105
iterating, 108–113
operators
aliases, 46–47
@ alias, 51–52
and alias, 49–50
Boolean aliases, 50–51
not alias, 48–49
or alias, 49–50
arithmetic operators, 33–35
assignment operators, 35–39
comparison operators, 39–42
existential operator, 43–46
string operators, 42–43
options for Cake tasks, 163–167
or alias, 49–50
output flag,
overriding functions, 142–145
P
parentheses, 16–17
comprehensions, 117
functions, calling, 72
print flag, 10
prototype function, 110
prototype functions, 150–151
Q-R
querying todo list application, 227–228
quitting REPL,
ranges, 90–96
reverse ranges, 91–92
regular expressions, extended regular expressions, 31
REPL, –
(back slashes),
Node.js, 194
quitting,
replacing array values, 94–95
retrieving attributes from objects, 101–103
reverse ranges, 91–92
running Cake tasks, 163
S
scope in classes, 127–137
servers (Node.js), creating, 195–197
server-side, building todo list application, 217
setting up Jasmine, 172–175
short options, 163
significant whitespace, 14–16
slicing arrays, 92–94
splats, 75–79
streaming APIs, writing with Node.js, 197–199
string interpolation, 23–25
string operators, 42–43
strings
heredocs, 28–29
literal strings, 25–28
switch case statements, 60–63
synchronous programming, 151
syntax
function keyword, 16
parentheses, 16–17
ranges, 90
significant whitespace, 14–16
T
tasks
Cake
invoking, 167–169
options, 163–167
running, 163
writing, 162–163
TDD (test-driven development), 171
terminating REPL,
testing
with Jasmine, 175–176
beforeEach function, 181–187
matchers, defining, 187–190
TDD, 171
unit testing, 176–181
testing inclusion, Node.js app server, 214–215
todo list application
Backbone
configuring, 256–259
todos, creating, 265–268
todos, listing with a view, 263–265
client-side
building, 237–252
exisiting todos, listing, 247–248
form, creating, 242–247
jQuery, adding, 240–241
todos, deleting, 252
todos, updating, 248–251
controller, cleaning up, 232–236
server-side
building, 217
todo API, writing, 225–226
todos
creating, 228–230
finding, 227–228
updating, 230–232
views
adding, 268–273
deleting models from, 273–274
todo list application, building
Express, setting up, 218–222
MongoDB, setting up, 222–225
Twitter Bootstrap
todo list application
client-side, building, 237–240
U
unit testing with Jasmine, 176–181
unless statement, 58–60
until loops, 114–115
updating
todo list application, 230–232
todos in client-side todo list application, 248–251
V
var keyword, 19
variables, declaring
in CoffeeScript, 19–20
in JavaScript, 18–19
views
adding to todo list application, 268–273
models, deleting from (todo list application), 273–274
W-X-Y-Z
watch flag, 10–11
when keyword, 109–110
while loops, 113–114
writing
Cake tasks, 162–163
“describe” block (Jasmine), 175
todo API, 225–226
todo model with Backbone, 256–259