Errata
Eloquent JavaScript

These are the known mistakes in the second edition of the book. For errata in the first edition, see this page. To report a problem that is not listed here, send me an email.

Issues whose section title is followed by a superscript ¹ were fixed after the first print of the book, and will not be present in later prints. Those followed by ² were fixed in the third print.

Introduction

Page 4 (Why Language Matters¹): The sentence “You can probably imagine how how tedious…” duplicates the word how.

Chapter 2

Page 32 (while and do Loops²): The var name example unintentionally exits the loop when the dialog is canceled, because browsers have a built-in global variable name whose values are implicitly converted to strings.

Chapter 9

Page 157 (Repeating Parts of a Pattern): The paragraph at the top of the page claims that {,5} is equivalent to {0,5} in a regular expression. This is not the case (you have to include the zero).

Page 159 (The Date Type¹): The findDate function produces the wrong months. The second argument given to new Date should be Number(match[2]) - 1, subtracting one to compensate for the fact that months start at zero in this interface.

Page 162 (Backtracking²): The regular expression should have another + sign after the [\da-f] group to match what it is described as matching. The diagram for the expression is similarly missing an arrow looping back around the corresponding box.

Chapter 10

Page 185 (Slow-Loading Modules¹): In the code snippet for define, the second use of the every method is incorrect. The call should be to myMod.onLoad.forEach instead.

Chapter 11

Page 192 (Parsing¹): The example Egg program has its parentheses distributed incorrectly. One closing parentheses from the second line should be moved to the end of the last line.

Chapter 12

Page 209 (The Web²): In the third paragraph I claim that the U in “URL” stands for Universal, whereas it actually stands for Uniform.

Chapter 14

Page 242 (Mouse Motion¹): The example uses event.which to detect mouse button release. This only works in Chrome and Safari. See the updated code and comment for a better way.

Chapter 16

Page 281 (Curves¹): The text refers to the bezierCurve method. This method is actually called bezierCurveTo (as in the example code).

Page 282 (Curves¹): Where it says the picture shows a line from the left of the circle to the left of the quarter circle, it should definitely say right in both instances.

Chapter 17

Page 312 (Summary¹): The code example uses the statusCode property. This does not exist, since the property is actually called status.

Chapter 18

Page 316 (Fields²): The checked attribute in the file field at the bottom of the example doesn't mean anything, and should not be there.

Page 327 (Summary¹): “When the user has selected a field” should be “When the user has selected a file”.