Skip to content
gek hua edited this page Aug 29, 2013 · 28 revisions

Preface

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)

Item 6

The Point example shouldn't use a truthiness test to initialize its x and y fields, as Item 54 recommends.

Item 7

Page 27, Paragraph 3, 1st Sentence: "16-byte" should be "16-bit" (reported by Lon Ingram)

Item 9

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.)

Item 18

  • Page 57, Paragraph 4: "binds the name parameter" should be "binds the username parameter"
  • Page 59, Paragraph 1, 1st Sentence: "has no property called name" should be "has no property called username". (reported by Stein Magnus Jodal)

Item 25

There three code examples that call buffer.join() but they should call buffer.concat(). (reported by Brad Jesness)

Item 26

Page 75, 1st paragraph: The technique described is "partial application", not "currying".

Item 35

Page 95, 2nd paragraph: Change "variables of the constructor" to "parameters of the constructor".

Item 36

Page 97, Figure 4.6: The method name on the prototype object should be ".addChild", not "add.child". (reported by Stein Magnus Jodal)

Item 37

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)

Item 44

Page 117, first code example, Object.getPrototypeOf(o) should be Object.getPrototypeOf(x)

Item 45

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__".

Item 46

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 });

Item 52

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

Item 55

First extend() call needs opts passed in as its first argument. This applies to the code examples on both page 151 and 152.

Item 62

A couple broken function references (reported by Alexandre Abreu):

  • downloadABC calls downloadFiles23 but it should call downloadBC
  • downloadBC calls downloadFile3 but it should call downloadC
Clone this wiki locally