JavaScript: The Good Parts

Errata for JavaScript: The Good Parts

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.


Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted
Other Digital Version N/A
N/A

The supplemental code linked by the text, and the O'Reilly catalog, at http://examples.oreilly.com/9780596517748/ appears to have been replaced by some kind of game. Not only does this game not have anything to do with the book, but it also fails to run.

Anonymous  Jun 26, 2015 
Other Digital Version Location 1001

It seems that at least in the Kindle edition (Nov 2016), a "new" method is added to to the Function object, but then it is not used when instantiating a new mammal object, instead the standard "new" constructor is used i.e. "new Mammal('Herb the Mammal')" when for educational reasons should have used "Mammal.new('Herb the Mammal')".

Soferio  Nov 17, 2016 
Printed Page qq
statments diagram

var statements is not used anywhere. I guess it should be listed as one option in the statements diagram.

DavidFarago  Dec 28, 2018 
Printed Page 1
5

Diagrams starting with "var statements" and continuing on from there, aren't clear as to where whitespace needs to be used. Rule 5 says that "diagrams with one bar at each end allow whitespace to be inserted between any pair of tokens" but whitespace isn't necessary. So this leads to some sequences that aren't legal even by following tracks.

Anonymous  Feb 10, 2018 
Printed, Safari Books Online Page 9
"escaped character" railroad diagram

In the Strings section on Chapter 2 (Grammer), There is a railroad diagram marked "escaped character". One of the options is a forward slash ("/") which in fact is NOT escaped, and can be included in strings as-is.

Udi Finkelstein  Jan 02, 2017 
PDF Page 12
switch statement diagram

The diagram is saying the following situation would be impractical var a = "1"; switch (a) { case "1": alert(a); break; }, since the diagram is not allowing to use only one case clause and finish it with a disruptive statement. Also it is acceptable use of "default" statement without a consecutive disruptive, as follows: var a = "1"; switch (a) { case "1": alert(a); default: alert(a); } I really don't know whether it is a matter of a ECMAScript version or a tiny mistake. However, worth a look. Thanks!

Igor Andrade  Aug 31, 2014 
Printed Page 14-15
"Expression Statement" and "Expression" railroad diagrams

The lowest path of the "expression statement" railroad diagram shows that "delete {expression} {refinement}" is a legal expression statement; however, the "expression" railroad diagram shows that "delete {expression} {refinement}" is a legal expression. That suggests that "delete delete {expression} {refinement} {refinement}" would be a logical JavaScript statement. Also (combined with the "for statement" railroad diagram on page 13), it suggests that "delete {expression} {refinement}" would be a legal increment clause for a for loop declaration.

Evan Turner  Jun 30, 2015 
Printed Page 15
First paragraph

An "or" should be added to the last clause of the first sentence, so it becomes, "invoke a method, or delete a property from an object."

Evan Turner  Jun 30, 2015 
Other Digital Version 22,47,100,100
Just search the kindle version for 'beget' - all the instances found are errors

Although the Object.create/Object.beget confusion is marked in the errata sheet as being fixed in 2008, it still appears in the Kindle edition I bought in 2012. A search for 'beget' reveals 4 instances, all errors.

Anonymous  Aug 09, 2012 
Printed Page 22
"Prototype" section, second paragraph.

(This is not so much a mistake as a seriously-needed update.) In the book, Object.create() is introduced as a helper function you can define in your code to make things saner. Since the book was first written, Object.create() has become a built-in method in many Javascript interpreters. It should be introduced that way, e.g. as follows: Remove the two sentences, "The mechanism that Javascript provides to do this is messy and complex, but it can be significantly simplified. We will add a create method to the Object function." Replace with the sentence, "Most modern Javascript interpreters provide an Object.create() method to do this." ("Object.create()" should be monospaced.) At the end of the paragraph, before the code, add the sentence, "In case your Javascript doesn't support Object.create(), we can add it to the Object function." ("Object.create()" and "Object" should be monospaced.)

Steve Witham  Mar 28, 2014 
Printed Page 23
"Prototype" section, last paragraph before "Reflection" section.

"We will see more about the prototype chain in Chapter 6." should be "...in Chapter 5."

Steve Witham  Mar 28, 2014 
Safari Books Online 28
Paragraph starting at bottom of page ("When a function is invoked...")

This isn't a question or request for clarification. Instead, it's a comment about what I consider a confusing section. The text starts with an example "add" function stored in the variable "sum". That's simple enough. The function is presented as a standalone top-level function. The text then says that "this" is bound to the global object when this function is invoked. Still fine. It continues with, "when **the inner function** (emphasis mine) is invoked." That's where the discussion is confusing. What inner function? It's a confusing lead-in to a very important section about how to access members of the enclosing function from an inner function. But inner functions haven't been covered at that point. On second and subsequent readings, this part of the book is understandable. The first time through, it's confusing. It's still a great book. Ron

Ron Stewart  Mar 04, 2014 
Safari Books Online 28
Paragraph starting at bottom of page ("When a function is invoked...")

Stupid me. I need to clarify my previous errata submission. I said that the text starts with an example "add" function stored in the variable "sum." That's wrong. I should have said that the text starts by showing a call to the example function "add" defined at the start of the chapter, and that that "add" function is a top-level, standalone function, not an inner function. The rest of my previous submission says what I intended. Ron

Ron Stewart  Mar 04, 2014 
PDF Page 33
middle of page

That regular express removes white space from both beginning and end of line. Not only end of line.

Farokh  Jan 30, 2017 
Printed Page 38,39
3rd paragraph of p. 38, 1st paragraph of p.39

3rd paragraph of p. 38: 'If it hasn't gotten to white yet...' This implies that the author is taking us through the loop until level == 15. 1st paragraph of p.39 'But this time, fade's level is 2.' Is it?

Bhakti Devananda  Sep 20, 2015 
ePub Page 39

Better example in closures section modes[i] should be nodes[i].

Mark A. Baldridge  May 10, 2013 
ePub Page 39
line 8. Kindle edition

This error is in the Kindle edition and remains in the 2012 revision of the online code examples at http://examples.oreilly.com/9780596517748/ modes[i].onclick = helper(i); should be: nodes[i].onclick = helper(i);

Anonymous  Jun 01, 2014 
Mobi Page 47
code block

"var that = Object.beget(this.prototype);" should be "var that = Object.create(this.prototype);"

Anonymous  Sep 23, 2013 
Mobi Page 48
2nd code example

I get a 'TypeError: Number.integer is not a function' when running the following code: Number.method('integer', function ( ) { return Math[this < 0 ? 'ceil' : 'floor'](this); }); (-10 / 3).integer( ); If integer is added directly to the prototype this way, then it works: Number.prototype.integer = function ( ) { return Math[this < 0 ? 'ceil' : 'floor'](this); }; (-10 / 3).integer( ); //=> -3

Matt Morrow  Nov 23, 2013 
Printed Page 50
bottom code sample

myMammal object doesn't have a "saying" function so the the says function would not work unless augmented later as is done by the mycat object.

Don Kleppinger  Mar 22, 2013 
Printed Page 51
First paragraph.

This only makes sense if my suggestion to introduce Object.create() as a builtin on page 22, is taken. Replace "the Object.create method from Chapter 3." with "the Object.create() method."

Steve Witham  Mar 28, 2014 
Printed Page 54
1st para of narrative, 2nd code listing

May 2008 edition capitalization of Cat and Mamma1 does not agree between narrative and source code. Not sure which should change, probably the code so that the constructor functions are capitalized.

gwideman  Mar 29, 2012 
Printed Page 59
On Page 59 toward the bottom:

​The [] postfix subscript operator converts its expression to a string using the expression's toString method if it has one. ​The word expression first indicates the contents of the brackets. It is the object's toString method which is invoked. The object in this case is an array. One could rewrite this method, which is super cool. So, I just recommend revising the sentence to: ​The [] postfix subscript operator converts the contents of the brackets to a string using the ​object's toString method if it has one. In this case, the object is an array; the toString method is invoked coercing integers to Strings. Array['10'] and Array[10] are equivalent.​

Anonymous  Nov 25, 2014 
Printed Page 62
last paragraph, first sentence

This only makes sense if my suggestion to introduce Object.create() as a builtin on page 22, is taken. (It also only makes sense if the modern Object.create() method still does not work on arrays!) Replace "the Object.create method from Chapter 3" with "the Object.create() method".

Steve Witham  Mar 28, 2014 
Printed Page 66
First paragraph of section "An Example"

The regular expression "parse_url" raises the JSLint error "insecure" three times. Should this regular expression not better be updated to match JSLint rules? Suggestion: parse_url = /^(?:([A-Za-z]+):)?(\/{0,3})([0-9.\-A-Za-z]+)(?::(\d+))?(?:\/([a-zA-Z0-9.\-_~!$&\u0027()*+,;=:@\/%]*))?(?:\?([a-zA-Z0-9.\-_~!$&\u0027()*+,;=:@\/%]*))?(?:#([a-zA-Z0-9.\-_~!$&\u0027()*+,;=:@\/%]*))?$/;

Harms Mller  Feb 25, 2014 
Printed Page 72
top of the page

The make_a_matcher() example does not return 10 for y.lastIndex; instead, it returns 0. Maybe RegExp objects made by regular expression literals do not share a single instance? See http://stackoverflow.com/questions/1326374/are-regex-literals-always-regexp-objects

Anonymous  May 06, 2013 
PDF, ePub Page 73
the last two paragraphs in "Regexp Factor" section

The text reads: "An unescaped ^ matches the beginning of the text when the lastIndex property is zero. It can also match line-ending characters when the m flag is specified. An unescaped $ matches the end of the text. It can also match line-ending characters when the m flag is specified." It is identically stated of ^ and $ that they "can also match line-ending characters when the m flag is specified." It would be more appropriate with ^ to specify that: "It can also match immediately after line-ending characters when the m flag is specified."

Alfredo Delgado  May 26, 2014 
Safari Books Online 74
3rd paragraph

The RegExp: var doubled_words = /([A-Za-z\u00C0-\u1FFF\u2800-\uFFFD]+)\s+\1/gi; will match any pair of identical strings of one or more letters separated by a space. That means it will return many false positives where a substring at the end of one word matches a substring at the start of the following word. Matching false positives may prevent it from finding actual duplicated words. For example: "the end end".match(doubled_words); returns ["e e"], a match against the last letter in "the" and initial letter in "end". Consequently, it fails to match against the duplicated "end"s.

Cathal Murray  Dec 21, 2014 
Printed Page 75
Chapter 7, Regex class example

I believe this is a May 2008 print. On the bottom of the page, under the "Could be written as:" the closing square bracket is not escaped. So it should be "\[|\\|\]" instead of "\[|\\|]". It's hard to spot, and I guess anybody get the gist of the example anyway.

Csaba Toth  Apr 28, 2013 
PDF Page 80
4.12.1 Paragraph 1

The word "propogates" should be "propagates".

myffical  Mar 25, 2013 
Printed Page 83
The whole page

I purchased a brand new printed copy through Amazon on 7/29/15 and received the book on 8/7/15. I am finally getting around to reading it. I finished page 82 and the next page was 99. I am literally missing pages 83 through 98. The book is brand new and the binding is in perfect condition. The pages were not torn out and non have fallen out due to a weakened binding. They were never inserted by the printer. Amazon.com LLC was the seller. I am putting in a complaint with Amazon.

Philip Krueger  Aug 27, 2015 
Printed Page 86
end of Object section

Erratum for my erratum about Object.create(). It should say "more an important update" not "more and". Btw, the last paragraph there is part of the text I think should be inserted (not just commentary). The reason I suggest adding an entry for Object.create is that if (as I suggest) you start treating Object.create as part of the language, a reader might then think page 86 is the logical place to look for info about it.

Steve Witham  Mar 30, 2014 
Mobi Page 139
3rd para from bottom

"produced the HTML. eval ing text" should be "produced the HTML. evaling text"

Anonymous  Sep 23, 2013 
Printed Page 151
Object.create() method

My copy says [2011-04-08]. The Object.create() index entry should list page 22 where Object.create() is introduced and explained. I haven't looked through the paper book for other missed instances, but 22 is the most important.

Steve Witham  Mar 28, 2014 
Printed Page 151
entry for "Obejct.create method

My edition says [2011-04-08]. If suggestion is taken to add Object.create entry on page 86, then add 86 to this entry in the index. I see that if any number of lines were added to page 86, other entries on later pages would move to new pages! Hoping your index is automatic. By the way, "If you lived in Github, you'd be accepting a pull-request by now."

Steve Witham  Mar 30, 2014