Errata
The "JavaScript vs ECMAScript" description explains the history as a question of copyright; it is more accurately described as a question of trademark. (reported by Brian Tingle)
The Point
example shouldn't use a truthiness test to initialize its x
and y
fields, as Item 54 recommends.
Page 27, Paragraph 3, 1st Sentence: "16-byte" should be "16-bit" (reported by Lon Ingram)
Note that accidental creation of globals is prevented in ES5 strict mode, because assigning to an unbound variable is an error and throws an exception. (Leaving off a var
can still lead to nasty bugs if the variable name happens to coincide with a variable that already exists in an outer scope.)
- Page 57, Paragraph 4: "binds the
name
parameter" should be "binds theusername
parameter" - Page 59, Paragraph 1, 1st Sentence: "has no property called
name
" should be "has no property calledusername
". (reported by Stein Magnus Jodal)
There three code examples that call buffer.join()
but they should call buffer.concat()
. (reported by Brad Jesness)
Page 75, 1st paragraph: The technique described is "partial application", not "currying".
Page 95, 2nd paragraph: Change "variables of the constructor" to "parameters of the constructor".
Page 97, Figure 4.6: The method name on the prototype object should be ".addChild", not "add.child". (reported by Stein Magnus Jodal)
According to the page "This seemingly simple code has a major but subtle bug: The callback passed to lines.map refers to this, expecting to extract the regexp property of the CSVReader object. But map binds its callback’s receiver to the lines array, which has no such property." However, if the second parameter of map is not in use, the global object (in this case window) associated with callback will be used instead, and not the lines array. (reported by Tan Gek Hua)
Page 117, first code example, Object.getPrototypeOf(o)
should be Object.getPrototypeOf(x)
Another viable implementation approach is to add a prefix string like "%"
, "$"
, or "~"
to every dict entry's internal property name, to ensure that no entry can possibly be stored with the name "__proto__"
.
Page 123, code example: The argument to report()
is an array identical to in the "correct" version on the next page. The text around the example suggests that the argument should have been an object. The intention was probably along the lines of: (reported by Stein Magnus Jodal)
report({ Hank: 1110100,
Steve: 1064500,
Billy: 1050200 });
Things to Remember
"The Array constructor behaves differently if its first argument is a number."
should be
"The Array constructor behaves differently if its only argument is a number."
reported by Hemant Singal
First extend()
call needs opts
passed in as its first argument. This applies to the code examples on both page 151 and 152.
A couple broken function references (reported by Alexandre Abreu):
-
downloadABC
callsdownloadFiles23
but it should calldownloadBC
-
downloadBC
callsdownloadFile3
but it should calldownloadC