Errata


Print Print Icon

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



Version Location Description Submitted By
Other Digital Version ch04.txt
many locations in file

In the downloadable code archive for "JavaScript: The Good Parts" (http://examples.oreilly.com/9780596517748/9780596517748.zip), there are numerous instances where a minus sign (visible in the printed and online versions of the book) are replaced in the file by a three-character sequence, "−" (a with a caret, caret by itself, single-quote). I presume that this is a UTF-8 representation of an em-dash or en-dash or something like that. It should not be any of those characters, it should be the ASCII hyphen (character code 0x2D).

If the code in the archives is to be executed, all occurrences of this must be changed from the three-character junk to a hyphen; else the code simply will not run.

I have not yet examined the rest of the files in the code archive. PLEASE check the other files, don't wait for me or someone else to submit separate errata for each file!!

Anonymous 
Other Digital Version 1
code archive

The downloadable code archive for JavaScript: The Good Parts is located at http://examples.oreilly.com/9780596517748/9780596517748.zip. This archive appears to contain the code examples as they are presented in the first (May 2008) printing of the book. Many errors have since been found, and most of those errors found were corrected in the September 2008 printing and in the Safari Online edition. However, none of those corrections have been applied to the example code archive.

Please remedy this condition.

Thank you.

Anonymous 
Printed Page 18
first figure

Literal can be one of six literals.
5th box "function" should be "function literal".

Anonymous 
Printed Page 39
code snippet 'better example' on second half of page

The author likes to reuse the variable/parameter 'i'. This makes the code snippet confusing. Introducing 'k' makes things much clearer:

var add_the_handlers =
function (nodes)
{ var i;
for (i = 0;i < nodes.length; i++)
{ nodes[i].onclick =
function (k)
{ return function ()
{ alert(k);
}
}(i);
}
}

Haakon 
Printed Page 39
BETTER EXAMPLE

Not only is the BETTER EXAMPLE confusing, but it's also wrong.

alert(e) should be alert(i) to reflect the textual description of what the code is supposed to be doing.

Heikki Vesalainen 
Printed Page 39
first and second code examples

The lines of the introductory comments in both code examples on this page are too long for the printed version. The resulting line breaks cause invalid syntax due to the use of end-of-line comments.

The lines should be reformatted with shorter line length to avoid breaking as in the other examples in the book.

yacht 
Printed Page 53
code example at the bottom and the following page

If the emphasis in this example is supposed to be on security (or "privacy" as mentioned at the start of the section), the constructor must take a defensive "deep" copy of the provided "spec" object.

Otherwise, any invariants verified by the mammal() constructor can later be invalidated by an outside attacker by modifying the passed-in "spec" object, like this:

var spec = { name: 'Mr. Nice' };
var myMammal = mammal(spec);
spec.name = 'Dr. Evil';
myMammel.get_name(); // 'Dr. Evil'

To prevent this attack (or mistake), the mammal() constructor must copy the properties that are supposed to be private, down to immutable types like Number, String or Function:

var mammal = function (spec) {
var that = {},
name = spec.name,
saying = spec.saying;

that.get_name = function () {
return name;
};

that.says = function () {
return saying || '';
};

return that;
};

Now it's impossible to attack the private properties "name" and "saying" from the outside, assuming that spec.name and spec.saying have immutable (primitive) values in the first place.

yacht 
Printed Page 83
Main code example, six lines from the end

(I have the first printing, May 2008)

The length of the array is not reset if delta > 0.

Instead of :

} else if (delta > 0) {
k = 1;
while (shift_count) {
this[new_len - k] = this[len - k];
k += 1;
shift_count -= 1;
}
}

Read :

} else if (delta > 0) {
k = 1;
while (shift_count) {
this[new_len - k] = this[len - k];
k += 1;
shift_count -= 1;
}
this.length = new_len;
}


Robert Hughes 
Printed Page 86
Fifth line of code from the foot

(This error is in the first printing, May 2008.)

In the comments at the beginning of the code example at the foot of the page, instead of :

// [1] The tag name
// [2] The /, if there is one

Read :

// [1] The /, if there is one
// [2] The tag name

Robert Hughes 
Printed Page 88
After the second line of code at the top of the page

(This error is in the first printing, May 2008.)

The last two tags have dropped out completely. The extended comment beginning

// Result:

on p.87 now finishes as follows on p.88 :

// [2] p
// [3]

It should finish like this :

// [2] p
// [3]

// [0] </body>
// [1] /
// [2] body
// [3]

// [0] </html>
// [1] /
// [2] html
// [3]

Robert Hughes 
Printed Page 101
First line of text

(First prinitng, May 2008)

For "In this chapter", read "In this appendix"

Robert Hughes 
Other Digital Version 113
B.9

var foo = function foo() {};
should be:
var foo = function () {};


John 


"I find Douglas Crockford's perspective on JavaScript in JavaScript: The Good Parts to be useful in my own relationship with JavaScript. His style is accessible and intelligent."
--Anita Kuno, Slashdot.org