JavaScript: The Definitive Guide

Errata for JavaScript: The Definitive Guide

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. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

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



Version Location Description Submitted By Date Submitted Date Corrected
Printed
Page passim
passim

The spelling varies between "same-origin policy" and "same origin policy". A more consistent spelling is welcome.

Note from the Author or Editor:
Found on page 513; replaced "same origin" with "same-origin".

Saašha Metsärantala  Dec 29, 2011  Aug 29, 2014
Printed
Page XV
Chapter "Errata and how ..."

The web site for errata http:/oreilly.com/catalog/9780596805531 should read http://oreilly.com/catalog/errata.csp?isbn=9780596805531

Lutz Adam  Jan 21, 2012  Aug 29, 2014
Printed
Page various
various

In my eyes the message of section 6.2.3 is, that if(book.subtitle) should make sure the existence of this property. But according to section 15.5.2 such a simple "if(...)" does not take care of an empty string. In both situations I don' t understand, why the in-operator (see section 4.9.3) must stay unused for those questions.

Note from the Author or Editor:
Change code sample to: // A verbose and explicit technique var len = undefined; if (book) { if ("subtitle" in book) len = book.subtitle.length; } // A concise and idiomatic alternative to get subtitle length or undefined var len = book && ("subtitle" in book) && book.subtitle.length;

Anonymous  Sep 02, 2013  Aug 29, 2014
Printed
Page page 405
code

var args = document.referrer.substring( ref.indexOf("?") + 1). split("&"); Flanagan, David (2011-04-18). JavaScript: The Definitive Guide (Definitive Guides) (p. 405). O'Reilly Media. Kindle Edition. correct version:var args = document.referrer.substring( referrer.indexOf("?") + 1). split("&");

Note from the Author or Editor:
Change line to: var args = document.referrer.substring(document.referrer.indexOf("?")+1).split("&");

Maria Grynychyn  Dec 29, 2013  Aug 29, 2014
Safari Books Online
1
Table of Contents

In the Safari Online PDF (which is no longer labeled as a Rough Cut), in the PDF table of contents for Parts III and IV, the different entries don't actually take you to their associated pages. This DRASTICALLY reduces the usefulness of this PDF as a reference.

Note from the Author or Editor:
Resolution: Is this still a problem? Sounds like something to fix. I don't know what a Safari PDF is unless it is the same as the normal PDF, but available through safari to those who bought the rough cut...

Beau  Apr 30, 2011  Aug 29, 2014
Printed
Page 4
3rd comment in 1.1

variable could be written with a capital v

Note from the Author or Editor:
Change "variable is a symbolic name for a value." to "A variable is a symbolic name for a value."

Angelos Sphyris  Aug 05, 2013  Aug 29, 2014
Printed
Page 5
2nd paragraph of text

The use of . and [] for example could be better written: For example, the use of . and [] to refer to the value of an object property or array element yields an expression.

Note from the Author or Editor:
Rephrase as per description of error.

Angelos Sphyris  Aug 05, 2013  Aug 29, 2014
Printed
Page 6
4th line of comments

the comma before too should be omitted

Note from the Author or Editor:
Change wording to avoid the comma altogether: points[1].x - points[0].x // => 1: more complicated operands work, too becomes points[1].x - points[0].x // => 1: more complicated operands also work

Angelos Sphyris  Aug 05, 2013  Aug 29, 2014
PDF
Page 9
Last paragraph

The sentence in the last paragraph that reads: A function is a named and parametrized block... should read: A function is a named and parameterized block...

Note from the Author or Editor:
I suspect that the spelling of parametrized is a house style issue. I don't care either way. Please check and leave it as is if the e was dropped intentionally.

Javier Estrada  Jul 19, 2011  Aug 12, 2011
Printed
Page 11
code example for the "load" event

I couldnt get function hide to work. Instead, I used: function hide(event) { var target = event.target ? event.target : event.srcElement; //srcElement needed for IE8, target for Chrome and FireFox target.style.visibility = "hidden"; }

Note from the Author or Editor:
Changed code for function to: function hide(event) { // srcElement needed for IE8, target for Chrome and Firefox var target = event.target ? event.target : event.srcElement; target.style.visibility = "hidden"; }

Angelos Sphyris  Aug 05, 2013  Aug 29, 2014
Printed
Page 13
Example 1.1

The <tr> lines for Repayment period and Zipcode do not have matching </tr> codes. Although the code seems to work fine without them, I've always been told that it's "good programming practice" to include them. (I've also downloaded the code from the website, and found it also has the same problem.)

Note from the Author or Editor:
Added </tr> tags at end of the lines:

Clark Jones  Jul 06, 2013  Aug 29, 2014
Printed
Page 19
First sentence

"This part of the book, Chapters 2 though 12,...." should read "This part of the book, Chapters 2 through 12,..."

Note from the Author or Editor:
Make change as specified: "This part of the book, Chapters 2 through 12,..."

Mikael Strand  May 21, 2013  Aug 29, 2014
Printed
Page 33
4th paragraph (1st after lines of code)

when a negative value becomes larger than the largest representable negative number: From a mathematical point of view, this is incorrect and confusing. It should be rephrased in any of the following two ways: when a negative value becomes smaller than the smallest representable negative number or when the absolute value of a negative number becomes larger than the absolute value of the largest representable negative number

Note from the Author or Editor:
Change to when the absolute value of a negative number becomes larger than the absolute value of the largest representable negative number

Angelos Sphyris  Aug 23, 2013  Aug 29, 2014
PDF
Page 34
1st source code fragment

Number.MAX_VALUE + 1 evaluates to 1.7976931348623157e+308 instead of Infinity, like the affirmation in the code comment. The result of the expression Number.MAX_VALUE + 1 is equal to Number.MAX_VALUE. The equality can be verified with the following test: Number.MAX_VALUE + 1 === Number.MAX_VALUE that returns true. -Number.MIN_VALUE - 1 evaluates to -1.7976931348623157e+308 instead of -Infinity, like the affirmation in the code comment. The result of the expression -Number.MAX_VALUE - 1 is equal to -Number.MAX_VALUE. The equality can be verified with the following test: -Number.MAX_VALUE - 1 === -Number.MAX_VALUE that returns true.

Note from the Author or Editor:
Replace Number.MAX_VALUE + 1 with Number.MAX_VALUE * 2 and Number.MIN_VALUE -1 with Number.MIN_VALUE * 2; this does results in Infinity

Rogrio Moraes de Carvalho  Dec 23, 2012  Aug 29, 2014
Printed
Page 35
last line

hours in UTC time; depends on timezone Is this really so? I thought UTC time was absolute and it was the local time, which was dependent on the timezone.

Note from the Author or Editor:
Changed line to: later.getUTCHours() // hours in UTC time

Angelos Sphyris  Oct 01, 2013  Aug 29, 2014
Other Digital Version
36
Second set of examples in String Literals section

The comment describing the one-line string written on 3 lines is nested within the string literal. This makes the comment part of the string literal and the backslash is not part of a line continuation.

Note from the Author or Editor:
Move comment to precede the strings: // A string representing 2 lines written on one line "two\nlines" // A one-line string written on 3 lines. ECMAScript 5 only. "one\ long\ line"

Evan Thomas  Sep 09, 2011  Aug 29, 2014
Printed
Page 40
section 3.3, 7th paragraph

The first occurrence of the word 'truthy' is written in the font used for programme code. Perhaps this is a formatting error.

Note from the Author or Editor:
Set "truthy" in italic.

Angelos Sphyris  Oct 01, 2013  Aug 29, 2014
PDF
Page 41
Last paragraph

The last paragraph starts with the following sentence: "+, ==, != and the relational operators are the only ones that perform this special kind of string-to-primitive conversions" I believe that instead of "string-to-primitive conversions" it should've been "object-to-primitive conversions". Two reasons: 1) The specific conversion the author is probably referring to is described above using the "object-to-primitive" term 2) String is already a primitive, so the "string-to-primitive conversion" term makes no sense.

Note from the Author or Editor:
Change text to read "...perform this special kind of object-to-primitive conversions"

Anonymous  Jun 12, 2013  Aug 29, 2014
PDF
Page 43
4th paragraph under section 3.6 Wrapper Objects

The text 'There are not wrapper objects for the null and undefined values' should be changed to 'There are no wrapper objects for the null and undefined values'

Shuaib Mohammad  Sep 28, 2012  Aug 29, 2014
PDF
Page 43
4th paragraph (after the 1st sample code)

The following phrase is confusing: "Strings are not objects, though, so why do they have properties?". This affirmation is not true for every case. For example, in the following code, myString is an object: var myString = new String("this is my string"); I think that the text could be modified to: "Primitive strings are not objects, though, so why do they have properties?". Then, the author must explain the difference between primitive strings, and string objects. The String documentation on String global object has a topic, called "Distinction between string primitives and String objects" that is superb. The following sample code is enlightening: var s_prim = "foo"; var s_obj = new String(s_prim); console.log(typeof s_prim); // Logs "string" console.log(typeof s_obj); // Logs "object"

Note from the Author or Editor:
Change "Strings are not objects" to "Primitive strings are not objects"

Rogrio Moraes de Carvalho  Dec 24, 2012  Aug 29, 2014
Printed
Page 46
Table 3-2, lower left cell, middle

I have convinced myself that the text "[9] (1 nuemeric elt)" is using "elt" as an abbreviation for "element". However, I had to stop and think about this. It is generally better to introduce abbreviations when first using them.

Note from the Author or Editor:
If it is possible to so without word wrap, change "(1 numeric elt)" to "(one numeric element)"

Anonymous  Sep 17, 2011  Aug 29, 2014
PDF
Page 58
The paragraph before the topic title 4.2 Object and Array Initializers

"When any identifier appears by itself in a program, JavaScript assumes it is a variable and looks up its value." Until here, the information is correct. The topic 3.10.3 (Scope Chain) explain how the variable is look up through the source code. "If no variable with that name exists, the expression evaluates to the undefined value. In the strict mode of ECMA 5, however, an attempt to evaluate a nonexistent variable throws a ReferenceError instead." Even in EcmaScript 3, a nonexistent variable throws a ReferenceError. I used the following code to test. try { console.log(nonexistVariable); } catch (e) { console.log(e.toString()); } I got the following error: "ReferenceError: nonexistVariable is not defined". (All browsers throws the ReferenceError, but the messages are slightly different).

Note from the Author or Editor:
Replace sentence starting "If no variable..." with: If no variable with that name exists, an attempt to evaluate a nonexistent variable throws a ReferenceError instead.

Rogerio Moraes de Carvalho  Dec 25, 2012  Aug 29, 2014
PDF
Page 58
JavaScript source code after the 3rd text paragraph

The comment of the first line reserved word primary expression has the word "Evalutes" instead of "Evaluates".

Rogerio Moraes de Carvalho  Dec 25, 2012  Aug 29, 2014
Printed
Page 59
Last line on page.

The code example: var square = function(x) { return x * x; } should include a final semi-colon at the end of the line to reflect best practices as well as to continue the correlation between object and array literals that precede it (where this syntax is used properly): var square = function(x) { return x * x; };

Note from the Author or Editor:
Include a final semi-colon at the end of the line: var square = function(x) { return x * x; }; (The same example on page 7, though split across several lines, has a semicolon after the closing brace.)

Scott Marcus  Nov 29, 2011  Aug 29, 2014
Printed
Page 59
3rd paragraph

A single trailing comma is allowedundefined element. I can understand what is meant here, yet the sentence can prove somewhat confusing, because if we define: var a = [1,,3,] then a[3] is undefined. In fact, a[i] for all i >= 3 is undefined. I would emphasise the phrase not create and add a further sentence, such as: However any array access expression for an index after that of the last expression will necessarily evaluate to undefined.

Note from the Author or Editor:
Add wording: "However, any array access expression for an index after that of the last expression will necessarily evaluate to undefined." Did not emphasise the phrase "not create"

Angelos Sphyris  Oct 01, 2013  Aug 29, 2014
PDF
Page 60
3rd paragraph

This second expression specifies the name of the desired property OF the index of the desired array element. should read This second expression specifies the name of the desired property OR the index of the desired array element.

Note from the Author or Editor:
fix, please

None  Apr 27, 2011  Aug 12, 2011
PDF
Page 60
4th paragraph

I initially misinterpreted the sentence "If the value is not an object (or array), it is converted to one (see 3.6)." I thought that the value would be converted to either an object OR AN ARRAY (depending on context somehow) but this is not the case; it is always converted to an object. I suggest changing the end of this sentence to "..., it is converted to an object". This phrasing would have prevented my confusion.

Note from the Author or Editor:
Make change as per description of error.

None  Sep 18, 2011  Aug 29, 2014
PDF
Page 60
5th paragraph

In the first sentence in this paragraph, "when you know then name" should be "when you know the name".

Note from the Author or Editor:
Make change as in description of error.

None  Sep 18, 2011  Aug 29, 2014
Safari Books Online
60
2nd to last paragraph

Replace the following (change indicated in between asterisks): "...it can only be used when the property you want to access has a name that is a legal identifier, and when you know *then* name when you write the program." with: " it can only be used when the property you want to access has a name that is a legal identifier, and when you know *the* name when you write the program."

Anonymous  Jul 29, 2012  Aug 29, 2014
Printed
Page 60
5th paragraph

For "know then name" read "know the name".

Martin Leese  Dec 30, 2012  Aug 29, 2014
PDF
Page 60
2nd paragraph of the topic 4.4 Property Access Expressions

Note the asterisks in the following paragraph detached phrase: "This second expression specifies the name of the desired property *of* the index of the desired array element." The correct must be "or" instead of "of".

Note from the Author or Editor:
Already fixed in current version of PDF.

Rogerio Moraes de Carvalho  Dec 25, 2012  Aug 29, 2014
Printed
Page 60
5th paragraph

If the property name is a reserved word you must use the square bracket notation. However, the following works: var p = { "goto" : 1, "void" : 2 }; p.goto + p.void //=> 3

Note from the Author or Editor:
Commenter's example works correctly in both Firefox and Chrome, latest versions. Action: Comment out <!--is a reserved word or-->

Angelos Sphyris  Oct 01, 2013  Aug 29, 2014
Printed, PDF
Page 62
Table 4-1 JavaScript operators

This is really a question about an omission from Table 4-1. In the table of JavaScript operators, Table 4-1 starting on page 62, the expressions '[ ]', '( )' and '.' are omitted from the start of the table. Although these are really expressions rather than operators, most experienced programmers from other languages (e.g. C and Java) would want them to be there, for convenience. It is useful to think of them as operators when reading code. The book isn't a strict reference like the ECMAScript standard, it's a book for learning the language. FWIW, Crockford includes them in his 'operator precedence' table in JavaScript: The Good Parts (which I ended up referring to in order to find out about these expressions/operators). Please add them to the table!

Note from the Author or Editor:
Split this off into a new table at the end of the preceding section, with this text preceding the table: <para><xref linkend="exprPriority" /> gives the precedence for these expressions. They are all of higher priority than the operators shown in <xref linkend="operators" />. The expressions listed first have higher precedence than those listed last. Expressions separated by a horizontal line have different precedence levels. The column labeled A gives the expression associativity, which can be L (left-to-right) or R (right-to-left).</para>

Alan Rew  May 10, 2012  Aug 29, 2014
PDF
Page 75
Fourth line before 4.10 title

"If it finds it, then o is an instance of f (or of a superclass of f) and the operator returns true." Shouldn't it be "a subclass of f"? Otherwise the Liskov Subtitution Principle would not be valid for JavaScript.

Note from the Author or Editor:
Correct. If I ask whether a Date is an instanceof Object, the answer is yes, because Date is a subclass of Object. Action: change "a superclass of" to "a subclass of"

Sergio Arbeo  Sep 17, 2011  Aug 29, 2014
PDF
Page 75
examples near top of page

Lines 2, 3, 4, 6, 7 and 8 should not have semicolons, to match the style of other examples in the book. In other examples, statements end in semicolons while expressions such as '1 + 2' or (here) 'd instanceof Date'' do not.

Note from the Author or Editor:
Remove semicolons from lines containing expressions: var d = new Date(); // Create a new object with the Date() constructor d instanceof Date // Evaluates to true; d was created with Date() d instanceof Object // Evaluates to true; all objects are instances of Object d instanceof Number // Evaluates to false; d is not a Number object var a = [1, 2, 3]; // Create an array with array literal syntax a instanceof Array // Evaluates to true; a is an array a instanceof Object // Evaluates to true; all arrays are objects a instanceof RegExp // Evaluates to false; arrays are not regular expressions

None  Sep 18, 2011  Aug 29, 2014
Safari Books Online
75
3rd paragraph

Section 4.9.4: The InstanceOf Operator Last sentence of 2nd text paragraph (ignoring code sample) reads: If the right-hand side is not a function, it throws a TypeError. I believe "function" should be "object" or "Class of Objects".

Note from the Author or Editor:
Reword to "If the right-hand side is not a class of objects,..."

Greg Edwards  Mar 22, 2013  Aug 29, 2014
PDF
Page 77
3d paragraph, second code example

function copy(o, p) { p = p || {}; // If no object passed for p, use a newly created object. // function body goes here } I believe properties of O should be assigned to P. function copy(o, p) { p = o || {}; // If no object passed for p, use a newly created object. // function body goes here }

Note from the Author or Editor:
Make change as specified in description of error.

Vctor  Dec 11, 2013  Aug 29, 2014
PDF, Other Digital Version
Page 80
First paragraph, Last sentence

If this isn't a typo, the intended meaning isn't clear. If the string throws an exception, the eval() propagates that expression. should be If the string throws an exception, the eval() propagates that exception.

Note from the Author or Editor:
Change it to: If the evaluated string throws an exception, that exception propagates from the call to eval().

Andrew Hart  Jun 11, 2011  Aug 12, 2011
Safari Books Online
84
1st example at "4.13.3 The delete Operator"

The delete operator example for array at 4.13.3 is described below, however, I've found that a.length is still 3 even after "delete a[2]" on my FireFox5 and Chorme14. var a = [1,2,3]; // Start with an array delete a[2]; // Delete the last element of the array a.length // => 2: array only has two elements now The specification of delete operator on FireFox at https://developer.mozilla.org/en/JavaScript/Reference/Operators/Special_Operators/delete_Operator says that "When you delete an array element, the array length is not affected." so this example is wrong.

Note from the Author or Editor:
Change this line: a.length // => 2: array only has two elements now To these two lines: 2 in a // => false: array element 2 doesn't exist anymore a.length // => 3: note that array length doesn't change, though Line the comments up with the ones above, of course. Also, if you can make it fit somehow, add the following at the end of the paragraph that follows after "with the in operator (4.9.3).": Deleting an array element leaves a "hole" in the array and does not change the array's length. The resulting array is <emphasis>sparse</emphasis> (see 7.3).

Shigeki Ohtsu  Jun 29, 2011  Aug 12, 2011
PDF
Page 84
last line in the first example group

a.lenth should be a.length Apparently fallout from fixing the confirmed erratum on this line (reported by Shigeki Ohtsu), since the typo does not appear in that report.

Note from the Author or Editor:
change a.lenth to a.length

None  Sep 19, 2011  Aug 29, 2014
Printed
Page 92
Section 5.3.2: 1st line on page 92

Like variables declared with var, functions defined with function definition statements are implicitly "hosted" ... should read: Like variables declared with var, functions defined with function declaration statements are implicitly "hosted" ...

Note from the Author or Editor:
Change text to: "...functions defined with function declaration statements are implicitly hoisted to the top of the containing script or function"

April  Sep 06, 2011  Aug 29, 2014
PDF
Page 95
repeated if/else -> switch statement example

The comments for the switch statement cases are using the wrong equality operator. In the book: "Start here if n == x" Correct: "Start here if n === x" Explanation: The switch statement uses the strict equality operator to determine which case to branch to as you mention yourself just a few lines above the example. The comments should therefore use the correct equality operator.

Note from the Author or Editor:
Change "==" to "===" in three comments on page 95.

Ole Rasmussen  May 20, 2011  Aug 12, 2011
PDF
Page 95
third paragraph

The section on switch statements includes this statement: "Various locations in the block of code are labeled with the case keyword followed by an expression and a colon. case is like a labeled statement". But labeled statements haven't been covered yet (they are covered later in the chapter), so it is odd to use it in as an analogy.

Note from the Author or Editor:
Confirmed. Added a link to the appropriate section: ...is like a labeled statement (see <xref linkend="labeledstatements" />), except that instead of giving the labeled statement a name

Anonymous  Jan 09, 2012  Aug 29, 2014
Safari Books Online
119
code example in 6.2.1

The example is missing the right curly bracket in the for-loop as below. var addr = ""; for(i=0; i < 4; i++){ add += cusotmer["address" + i] + '\n';

Note from the Author or Editor:
Remove the unbalanced "{" after "i++)". Note that this code is on page 121 in my pdf.

Shigeki Ohtsu  Jul 12, 2011  Aug 12, 2011
PDF
Page 127
function merge....

function merge(o, p) { ..... if (o.hasOwnProperty[prop]) continue; .... } Shouldn't the square brackets be round brackets instead? ie. if (o.hasOwnProperty(prop)) continue;

Note from the Author or Editor:
Change square brackets to round brackets as in description of error.

Jeremy Peck  Aug 17, 2011  Aug 29, 2014
Printed
Page 127
in code for function merge()

The code in function merge() should have parentheses surrounding prop rather than square brackets in the line: if (o.hasOwnProperty(prop)) continue; NOT if (o.hasOwnProperty[prop]) continue; Also, in all of the examples on page 127, it would be better to include a var expression inside the for/in loop. That is: for (var prop in p) instead of for (prop in p)

Note from the Author or Editor:
Square brackets -> parentheses is a duplicate; change for (prop in p) to for (var prop in p) in all examples on page 127; also change for (p in o) to for (var p in o) in examples on pages 126 and 127.

Jeff Tash  Nov 12, 2012  Aug 29, 2014
Printed
Page 128
2nd function

The function "union"'s comment section notes that "If o and p have properties by the same name, the values from o are used". It should read "the values from p are used".

Note from the Author or Editor:
change the comment as the reader suggests

Dave Gibson  Jun 02, 2011  Aug 12, 2011
Safari Books Online
128
code example in 6.6

The code example below is for obtaining a polar coordinate of (0,0) with the inherited object. The radius and theta at the coordinate origin point are not intuitive so that it's better to change the point into (0,1) or whatever not (0,0) var q = inherit(p); q.x = 0, q.y = 0; console.log(q.r); console.log(q.theta);

Note from the Author or Editor:
Change this line: q.x = 0, q.y = 0; // Create q's own data properties To this: q.x = 1; q.y = 1; // Create q's own data properties Note the numbers change and the comma changes to a semicolon. Note also that this is on page 130 of my pdf.

Shigeki Ohtsu  Jul 12, 2011  Aug 12, 2011
PDF
Page 128
1/3 below the top of the page

The function "function union(o,p) { return extend(extend({},o), p); }" has the following comment: >>> If o and p have properties by the same name, the values from o are used. The values from o are actually being OVERWRITTEN based on the order of parameters. If he wants o to be used, then he has use p first, that is return extend(extend({},p),o); To keep this simple, please change the comment to "the values from o are overwritten by those of p." For discussion, here: http://stackoverflow.com/questions/7019807/the-definitive-guide-6ed-error

Note from the Author or Editor:
Latest XML source for the book already has this change. The line now reads: If o and p have properties by the same name, the values from p are used.

Yeukhon Wong  Aug 11, 2011  Aug 29, 2014
Printed
Page 130
Serial number example

The comment in the code and the error message thrown state that the new value must be larger than the existing value. However, the code accepts equal values in the 'if' test: n >= this.$n Strictly speaking, the test should be: n > this.$n

Note from the Author or Editor:
Change line to if (n > this.$n) this.$n = n;

David Sletten  Dec 18, 2012  Aug 29, 2014
Printed
Page 135
code at bottom

Object.prototype.isPrototypeOf(o) // => true: p inherits from Object.prototype Should read, Object.prototype.isPrototypeOf(o) // => true: o inherits from Object.prototype

Note from the Author or Editor:
The reader is correct that there is a problem, but the proposed solution is wrong. Change the line: Object.prototype.isPrototypeOf(o) // =>; true: p inherits from Object.prototype To: Object.prototype.isPrototypeOf(p) // =>; true: p inherits from Object.prototype

Evan Carroll  Jun 20, 2011  Aug 12, 2011
Printed
Page 135
Middle of page

The text states that objects created by means of Object.create() have a constructor property that refers to the Object() constructor. However, both Chrome (23.0.1271.64) and Safari (5.1.7) report: Object.create(new Date()).constructor => function Date() { [native code] } The book is correct, however, in explaining that constructor.prototype here does not refer to the correct prototype: var d = Object.create(new Date()); d.constructor.prototype === Object.getPrototypeOf(d) => false d.constructor.prototype === Object.getPrototypeOf(Object.getPrototypeOf(d)) => true

Note from the Author or Editor:
Change "Note that objects created by object literals or by Object.create() have a constructor property that refers to the Object() constructor." to: "Note that objects created by object literals or by Object.create() with an object literal as their first argument have a constructor property that refers to the Object() constructor."

David Sletten  Dec 21, 2012  Aug 29, 2014
Printed
Page 143
3

The second sentence of this paragraph reads: "All indexes are property names, but only property names that are integers between 0 and 2^32 - 1 are indexes." This is misleading. According to the ECMAScript spec (section 15.4, both the 3rd and 5th edition): "A property name P (in the form of a String value) is an array index if and only if ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal to 2^32 - 1." So the second sentence of your paragraph should read: "All indexes are property names, but only property names that are integers between 0 and 2^32 - 2 are indexes." Thanks so much for writing this book!

Note from the Author or Editor:
Good catch! Change 2<superscript>32</superscript>-1 to 2<superscript>32</superscript>-2

Anonymous  May 08, 2011  Aug 12, 2011
PDF
Page 144
5th paragraph ("Note that when you omit...")

quote from Ch. 7.3 p. 144 >>> "Note that when you omit value in an array literal, you are not creating a sparse array. The omitted element exists in the array and has the value undefined. This is subtly different than array elements that do not exist at all. You can detect the difference between these two cases with the in operator: var a1 = [,,,]; // This array is [undefined, undefined, undefined] var a2 = new Array(3); // This array has no values at all 0 in a1 // => true: a1 has an element with index 0 0 in a2 // => false: a2 has no element with index 0" <<< end of quote However, v8 implementation of this differs from what the book suggests; both "0 in a1" and "0 in a2" are false. Also, the developers say v8 follows the ECMAScript specification. If that is true, the quoted text is erroneous. The issue is discussed in the following v8 bug which also contains a quote from the ECMAScript specification: http://code.google.com/p/v8/issues/detail?id=1371

Note from the Author or Editor:
Resolution: Yuck! The 4th paragraph of page 144 plus the 4 lines of code after it plus the one line paragraph after the code all have to be removed and replaced with the following: Note that when you omit a value in an array literal (using repeated commas as in <literal>[1,,3]</literal>) the resulting array is sparse and the omitted elements simply do not exist: var a1 = [,]; // This array has no elements and length 1 var a2 = [undefined]; // This array has one undefined element 0 in a1 // => false: a1 has no element with index 0 0 in a2 // => true: a2 has the undefined value at index 0 Some older implementations (such as Firefox 3) incorrectly insert the <literal>undefined</literal> values in array literals with omitted values. In these implementations <literal>[1,,3]</literal> is the same as <literal>[1,undefined,3]</literal>. Also, on page 142, the 3rd paragraph and the two lines that follow and the paragraph after that must be changed as follows: If an array literal contains multiple commas in a row, with no value between, the array is sparse (see 7.3). Array elements for which values are omitted do not exist, but appear to be <literal>undefined</literal> if you query them: var count = [1,,3]; // Elements at indexes 0 and 2. count[1] => undefined var undefs = [,,]; // An array with no elements but a length of 2 Array literal syntax allows an optional trailing comma, so <literal>[,,]</literal> has a length of 2, not 3. Hopefully these two changes sort of balance each other out and do not cause too many page break changes. Let me know if you need to shorten or lengthen them.

Marja Hölttä  May 09, 2011  Aug 12, 2011
Printed, PDF
Page 147
1st paragraph code example

In section 7.6 "Iterating Arrays", a code example is given which shows a technique for "exclud[ing] null, undefined, and nonexistent elements" while iterating through a sparse array. The important bit is: if (!a[i]) continue; // Skip null, undefined, and nonexistent elements However, this conditional will also exclude falsy elements, which does not appear to match the intention of the technique. Either this should be mentioned in the text or the conditional should be changed.

Note from the Author or Editor:
Change if (!a[i]) continue; to: if (a[i] === null || a[i] === undefined)

Louis Wust  Jun 29, 2013  Aug 29, 2014
Printed
Page 148
Section 7.8

for "under Array in the client-side reference section" read "under Array in the core reference section".

Note from the Author or Editor:
Change as per description of error.

Martin Leese  Dec 30, 2012  Aug 29, 2014
Printed
Page 150
First Line

return a-b; //Returns < 0, 0, or > 0, depending on order should read return a-b; //Returns < 0, 0, or > 0, depending on order

Note from the Author or Editor:
Change as per description of error.

Anonymous  Oct 10, 2011  Aug 29, 2014
Printed
Page 151
Paragraph 2

The book discusses what happens when the 2nd argument to splice() is omitted. However, section 15.4.4.12 of the standard does not identify the 2nd argument (deleteCount) as being optional in the splice() method signature. Furthermore, after describing the algorithm for splice(), the standard explicitly states: The length property of the splice method is 2. The algorithm (step 7) defines a value, actualDeleteCount, to be: min(max(ToInteger(deleteCount),0), len actualStart) When deleteCount is omitted its value is undefined. This appears to result in a value of 0 being assigned to actualDeleteCount. But this also seems to be the case when a value of 0 is passed for deleteCount. Yet the behavior is very different in the 2 cases. In Chrome/Safari/node.js when deleteCount is omitted, splice() behaves as the book describes. But when 0 is passed explicitly, no elts are removed. I'm missing something in my understanding of the algorithm, but should this behavior when deleteCount is omitted be relied on?

Note from the Author or Editor:
Add paragraph at end of section: Note also that the one-argument call to splice() is not defined in the ECMAScript 5 standard; it is an extension that works in modern browsers.

David Sletten  Dec 25, 2012  Aug 29, 2014
Other Digital Version
153
Last line of filter() section

The expression for the return statement in the example is "x !== undefined && x != null". Either use !== for both comparisons or simplify it to x != null.

Note from the Author or Editor:
Change x!= null to x !== null (consistent, and best practice)

Evan  Sep 26, 2011  Aug 29, 2014
Other Digital Version
156
Last paragraph of reduce(), reduceRight() section

The text states that "the union() function uses the value of that property from the first argument." Errata for the definition of union (on page 128) has corrected the description of union to use the value from the second argument.

Note from the Author or Editor:
Change "the first argument" to "the second argument".

Evan  Sep 26, 2011  Aug 29, 2014
Printed
Page 156
3rd example code

I found incorrect result at comment. Now var objects = [{x:1,a:1}, {y:2,a:2}, {z:3,a:3}]; var leftunion = objects.reduce(union); // {x:1, y:2, z:3, a:1} var rightunion = objects.reduceRight(union); // {x:1, y:2, z:3, a:3} I think result var objects = [{x:1,a:1}, {y:2,a:2}, {z:3,a:3}]; var leftunion = objects.reduce(union); // {x:1, y:2, z:3, a:3} var rightunion = objects.reduceRight(union); // {x:1, y:2, z:3, a:1} adjusting point // {x:1, y:2, z:3, a:1} -> // {x:1, y:2, z:3, a:3} // {x:1, y:2, z:3, a:3} -> // {x:1, y:2, z:3, a:1}

Note from the Author or Editor:
Change code to read: var leftunion = objects.reduce(union); // {x:1, y:2, z:3, a:3} var rightunion = objects.reduceRight(union); // {x:1, y:2, z:3, a:1}

Hitoshi Mori  Jul 10, 2012  Aug 29, 2014
Printed
Page 156
Paragraph 3

The book suggests using reduceRight() for a reduction operation with "right-to-left precedence". This term is meaningless as it stands and should be changed to "right-to-left associativity" consistent with the language of section 4.7.6 used to refer to a right-associative operator.

Note from the Author or Editor:
Change text as per description. ("precedence" becomes "associativity")

David Sletten  Dec 25, 2012  Aug 29, 2014
Printed
Page 157
Paragraph 4

The book states that the string indexOf() and lastIndexOf() methods work like the corresponding array methods do. This may be true overall, but one specific difference is that the string versions don't accept negative values for the 2nd optional position argument. According to section 15.5.4.7 (and 15.5.4.8) of the standard, both indexOf() and lastIndexOf() compute their starting index in terms of max(pos, 0), where pos is the result of ToInteger(position). Consequently, a negative position is simply treated as 0 for the string versions unlike the array versions.

Note from the Author or Editor:
Change text to read "methods that work like these array methods, except that a negative second argument is treated as zero."

David Sletten  Dec 25, 2012  Aug 29, 2014
Printed, PDF
Page 158
Between 3rd & 4th paragraph

The following code is incorrect: var isArray = Function.isArray || function(o) { return typeof o === "object" && Object.prototype.toString.call(o) === "[object Array]"; }; The Function.isArray should be Array.isArray so that it reads as: var isArray = Array.isArray || function(o) { return typeof o === "object" && Object.prototype.toString.call(o) === "[object Array]"; };

Note from the Author or Editor:
Change Function.isArray to Array.isArray as per description of error.

Anonymous  Nov 26, 2012  Aug 29, 2014
Printed, PDF
Page 159
2nd line from the bottom

"it does not property expand that object into the returned array." should read: "it does not properly expand that object into the returned array."

Note from the Author or Editor:
Make change as per description of error.

Mingway Huang  Aug 31, 2011  Aug 29, 2014
Printed
Page 159
Paragraph 2

The function isArrayLike() strives to weed out objects that are not array-like, particularly those simply possessing a length property. The comments indicate that strings are rejected by the function. This is true for string primitives but not for String objects which will evaluate to true by isArrayLike(). Furthermore, the upper limit for the value of length is not quite right. As pg. 141 correctly points at, and as the erratum reported for pg. 143 highlights, the length must be strictly less than Math.pow(2, 32) -1. So the function should either test: o.length < Math.pow(2, 32) - 1 or o.length <= Math.pow(2, 32) - 2

Note from the Author or Editor:
Change line from: o.length < 4294967296) // o.length < 2^32 to: o.length< 4294967295) // o.length &lt; 2^32 - 1

David Sletten  Dec 25, 2012  Aug 29, 2014
Printed
Page 160
Bottom of page

var s = test; Presumably intended: var s = "test";

Note from the Author or Editor:
Change as per detailed description.

David Sletten  Dec 25, 2012  Aug 29, 2014
Printed
Page 160
bottom of page

var s = test should be var s = "test"

Note from the Author or Editor:
Put in the quote marks.

Anonymous  Jun 29, 2014  Aug 29, 2014
PDF
Page 165
last sentence

Variable declarations are hoisted (see 3.10.1, but assignments... shoudld be: Variable declarations are hoisted (see 3.10.1), but assignments...

Note from the Author or Editor:
Yes, add the missing close paren

Anonymous  Jul 26, 2011  Aug 12, 2011
Printed
Page 165
Top of page

The book gives an example of a function expression that is invoked directly. But there does not seem to be any discussion in the book about the necessity of the enclosing parentheses around such an invocation. This is a syntax error (discussed in section 12.4 of ECMA-262): function(x) {return x*x;}(10) But either of these appears to be legal: (function(x) {return x*x;}(10)) (function(x) {return x*x;})(10) In fact, the example in the book does not seem to require the enclosing parentheses (in Chrome, Safari): var tensquared = function(x) {return x*x;}(10); But I'm not sure that this is consistent with the standard. Some mention of this issue (perhaps in section 4.5) would be helpful.

Note from the Author or Editor:
Add parentheses; line now reads: var tensquared = (function(x) {return x*x;}(10));

David Sletten  Dec 26, 2012  Aug 29, 2014
Safari Books Online
169
Section 8.2.2, second paragraph after the "Method Chaining" boxed note

David, In the sentence "Unlike variables, the this keyword does not have a scope, and nested functions to not inherit the this value of their caller.", I think you meant to say that nested functions do not inherit the this value of their "outer function". As you mention later in the paragraph, one might mistakenly assume that the inner function body has the this value in effect where it is defined (in the manner of a closure), but nobody would suspect that an inner function gets the *caller's* this. I'm seeing this in the rough cuts April 16th PDF version. Great book! Best Regards, Tom

Note from the Author or Editor:
Change "do not inherit the this value of their caller" to "do not inherit the <literal>this</literal> value of the containing function".

Anonymous  Apr 29, 2011  Aug 12, 2011
Printed
Page 169
Second paragraph after the text box

Unlike variables, the this keyword does not have a scope, and nested functions do not inherit the this value of the containing. -> Missing a word at the end of the sentence, probably "function".

Note from the Author or Editor:
Add word "function" at end of sentence.

Anonymous  Oct 11, 2011  Aug 29, 2014
Printed
Page 172
Bottom of page

In my opinion, the max() function could be improved: function max(x) { var max = x; for (var i = 1; i < arguments.length; i++) { if ( arguments[i] > max ) { max = arguments[i]; } } return max; } The original version takes the unusual step of initializing the maximum value with a value (Number.NEGATIVE_INFINITY) that is presumably not even one of the args passed to the function. Furthermore, it produces the odd behavior: max() => -Infinity (Of course, this is how Math.max() behaves...) But more importantly, I think it would be helpful to point out that in the example, the local variable 'max' shadows the function name. This is kind of an unusual situation and might cause problems for recursive functions.

Note from the Author or Editor:
While an improvement, the text says that see also the built-in function Math.max(), which behaves the same way, so I believe the code should indeed do what Math.max() does. Change var max to var maxValue to avoid the shadowing problem. function max(x) { var maxValue = Number.NEGATIVE_INFINITY; // Loop through the arguments, looking for, and remembering, the biggest. for(var i = 0; i < arguments.length; i++) if (arguments[i] >maxValue) maxValue = arguments[i]; // Return the biggest return maxValue; }

David Sletten  Dec 27, 2012  Aug 29, 2014
Printed
Page 175
Bottom of page

The function 'flexisum' declares a parameter 'a' that is never used. This may be a copy-paste error from the function 'sum' earlier on the page, which does use its parameter 'a'.

Note from the Author or Editor:
Remove parameter "a"; first line of function becomes function flexisum() {

David Sletten  Dec 27, 2012  Aug 29, 2014
Printed
Page 180
Bottom of Example 8-3

In Example 8-3, the nested patched_extend(o) function references the protoprops variable defined in its surrounding function, but the assignment of an array of strings to the protoprops variable is unreachable code. The declaration of the protoprops variable will be hoisted, but since the unnamed outer function will always return either the extend(o) or the patched_extend(o) function before the assignment statement itself is executed, the value of protoprops should always be undefined.

Note from the Author or Editor:
This is another good catch. Move the 4 lines beginning with the blank line before this one: // This is the list of... Up so that they appear right after this line: // properties of Object.prototype. You should end up with a 4-line comment block, followed by a blank line, followed by a one line comment, followed by 2 lines beginning "var protoprops = " followed by the line "return function patched_extend(0) {" and all the code that follows that. The example should still end with the line "}());"

Matthew Engel  Jul 27, 2011  Aug 12, 2011
Printed
Page 183
Bottom of page

Same issue as pg. 130. Test should be: m > n

Note from the Author or Editor:
Change m >= n to m > n

David Sletten  Jan 04, 2013  Aug 29, 2014
Printed
Page 186
3rd paragraph

JSDG appears to make note of where behavior differs in ECMA 3/5 throughout, and perhaps it should here as well: function check(args) { var actual = args.length; var expected = args.callee.length; if(actual !== expected) { throw Error("Expected " + expected + "args; got " + actual); } } with "use strict" I get the following expected exception from Firefox 9.0.1. TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. This is what I expect base on section 8.3.2.1 (page 173). So in ECMA5, is there any way to way write a function accomplishing the desire behavior?

Note from the Author or Editor:
Current PDF now has a comment: // This function uses arguments.callee, so it won't work in strict mode. (I do not know if it is possible to write this in strict mode.)

Ketil Wright  Jan 23, 2012  Aug 29, 2014
Printed
Page 188
Bottom of page

The function assigned to 'sum' is missing a semicolon from its return statement. The function 'f' is also missing a semicolon from its return statement and has an extraneous semicolon after the function statement.

Note from the Author or Editor:
Change code to read: var sum = function(x,y) { return x + y; }; function f(y,z) { return this.x + y + z; }

David Sletten  Jan 08, 2013  Aug 29, 2014
Printed
Page 190
First paragraph

The 6th edition of the book appears to replace the 5th edition terms "function definition statement" and "function literal [expression]" with the terms "function declaration statement" and "function definition expression". Page 190 reverts to the earlier terms.

Note from the Author or Editor:
Change "function definition statement" to "function declaration statement", and "function literal" to "function definition expression" as per description of error.

David Sletten  Jan 12, 2013  Aug 29, 2014
PDF
Page 191
2nd paragraph at 8.7.7 Callable Objects

in the book: "getElementsById()" should be: "getElementById()"

Note from the Author or Editor:
Make change as in description of error.

HIROKI OGASAWARA  Sep 20, 2011  Aug 29, 2014
Other Digital Version
192
implementation of reduce

The "if (i == len)" statement causes reduce to throw a TypeError when it is called with an array containing a single element and no initial value.

Note from the Author or Editor:
Change if (i == len) to if (i == len && len > 1)

Evan  Sep 26, 2011  Aug 29, 2014
PDF
Page 192
implementation of map

To explain my submission in detail the above, the map() function on the page 192 is defined for both ES3 and ES5, however, in ES5 it has an optional value of the object as the second argument. So it can be changed into the following so as to fit the exact specification of the Array.prototype.map in ES5. var map = Array.prototype.map ? function(a, f, o) { return a.map(f, o); } : function(a, f, o) { var results = []; for(var i = 0, len = a.length; i < len; i++) { if (i in a) results[i] = f.call(o || null, a[i], i, a); } return results; };

Note from the Author or Editor:
Changed code as provided. Code should read: var map = Array.prototype.map ? function(a, f, o) { return a.map(f, o); } // Use map method if it exists : function(a,f, o) { // Otherwise, implement our own var results = []; for(var i = 0, len = a.length; i < len; i++) { if (i in a) results[i] = f.call(o || null, a[i], i, a); } return results; }; Thank you for providing the code!

HIROKI OGASAWARA  Oct 25, 2011  Aug 29, 2014
Printed
Page 195
Bottom of page

The final example on the page uses partial() to define a function that returns the last "character" of a string. The example uses the substr() function. However, the reference entry for substr() on pg. 849 identifies this function as nonstandard and deprecated. Instead: String.prototype.last = partial(String.prototype.slice, -1);

Note from the Author or Editor:
Replace String.prototype.last = partial(String.prototype.substr, -1, 1); with String.prototype.last = partial(String.prototype.slice, -1);

David Sletten  Jan 13, 2013  Aug 29, 2014
Printed
Page 201
code example at top of page

The provided code does not work in Chrome, though is fine in Firefox. The snippet that throws errors in chrome is: foreach: function(f) {for(var x = Math.ceil(this.from); x <= this.to; x++ ) f(x);}

Note from the Author or Editor:
Change r.foreach(console.log) to the verbose solution: r.forEach(function(x) {console.log(x);})

Ben Petersen  Sep 07, 2011  Aug 29, 2014
Printed
Page 201
Top of page

As Ben Petersen previously noted, this sample code does not work: r.foreach(console.log) According to the following StackOverflow entry, the problem is related to aliasing the console.log function: http://stackoverflow.com/questions/5133649/alias-to-chrome-console-log The simple fix--bind to the 'console' object: r.foreach(console.log.bind(console)) Another more verbose solution--avoid the alias: r.foreach(function(x) {console.log(x);}) The problem occurs in Chrome and Safari, although Ben says Firefox works.

Note from the Author or Editor:
Change r.foreach(console.log) to the verbose solution: r.forEach(function(x) {console.log(x);})

David Sletten  Dec 31, 2012  Aug 29, 2014
PDF
Page 203
last line

c === F // => true: F.prototype.constructor==F for any function Should that comment be so? c === F // => true: F.prototype.constructor===F for any function

Note from the Author or Editor:
Sure. Change == in the comment to ===. And if it will fit, add spaces on both sides of ===. I probably used == to save space, but it looks like we can fit more characters on the line.

Anonymous  Aug 02, 2011  Aug 12, 2011
Printed
Page 203
Chapter 9.2.1, 2nd par.

[First line of paragraph] Even THROUGH constructors are not ... "THROUGH" should read "THOUGH"

Note from the Author or Editor:
Change "through" to "though"

Lutz Adam  Jan 19, 2012  Aug 29, 2014
Printed
Page 208
Section 9.4: First paragraph

<pre> Page 208: Section 9.4: First paragraph: ... an object inherits properties from its prototype, even if the prototype changes after the object is created. is at least misleading. 'prototype' is the name of a pointer/reference to a object which contains the prototypical properties since arrays/objects are referenced by pointer/reference (section 3.7). This is a perfect example of pointer/reference access to one object using different copies of the same pointer/reference. I think saying 'even if the prototype's properties, but not the actual prototype, changes, since the prototype is referenced by pointer/reference ...' would be clearer and let one see just why changes in the prototype do affect old objects. SAMPLE: ======= I will look at an object which is an instance of a class for which the prototype is created as a property of the constructor. I will use 'print' for output (the spider monkey stand alone interpreter's output function). If you change the prototype itself, the POINTER to the object of prototypical values, then new objects use the new prototype but *OLD OBJECTS USE THE OLD PROTOTYPE*. The new objects (objects created after the prototype changes) contain pointers to the new object containing the new prototype values while the old objects use the old prototype (pointer/reference to the old prototype's object). function Test1() {};Test1.prototype={a:1,b:2} T=new Test1 print(T.a);print(T.b);print(T.c) Test1.prototype={a:10,b:20,c:30} U=new Test1 print(T.a);print(T.b);print(T.c) print(U.a);print(U.b);print(U.c) gives 1, 2, undefined [original T before the prototype has changed] 1,2, undefined [original T AFTER the prototype has changed] <-- 10,20,30 [U - created AFTER the prototype has changed] T retains the old prototype, i.e. the pointer to the old prototype's object. On the other hand, if you change the CONTENTS of the prototype object but not the prototype (i.e. the pointer/object containing the values): function Test2() {};Test2.prototype={a:1,b:2} V=new Test2 print(V.a);print(V.b);print(V.c) Test2.prototype.a=10;Test2.prototype.b=20;Test2.prototype.c=30 W=new Test2 print(V.a);print(V.b);print(V.c) print(W.a);print(W.b);print(W.c) Then one gets: 1, 2, undefined [original V before the prototype has changed] 10,20,30 [original V AFTER the prototype has changed] <-- 10,20,30 [W - created AFTER the prototype has changed] If an instance of an class contained a reference to its constructor (instead of the constructor's prototype) and actually used that to access the prototype object of its class/constructor (rather than having a pointer to the prototype object used when it was constructed itself) then one could change the prototype object (not just its contents) (as a property of the constructor) and the changed prototype would affect both new *and old* instances: function Test3() {this.constructor=Test3}; Test3.prototype={a:1,b:2} X=new Test3 print(X.constructor.prototype.a);print(X.constructor.prototype.b);print(X.constructor.prototype.c) Test3.prototype={a:10,b:20,c:30} Y=new Test3 print(X.constructor.prototype.a);print(X.constructor.prototype.b);print(X.constructor.prototype.c) print(Y.constructor.prototype.a);print(Y.constructor.prototype.b);print(Y.constructor.prototype.c) produces: 1, 2, undefined [original X before the prototype has changed] 10,20,30 [original X AFTER the prototype has changed] 10,20,30 [Y - created AFTER the prototype has changed] Now I wonder what intricacies are created when a constructor which is an internal function to another is called - if the constructor's 'prototype' is set equal (f.prototype=p) to an internal variable of the containing function ... or various properties of the prototypical object are set equal to internal variables .... </pre>

Note from the Author or Editor:
Okay, change "even if the prototype changes" to "even if the properties of the prototype change"

Anonymous  Jul 05, 2011  Aug 12, 2011
Printed
Page 209
Top of page

A minor discrepancy with the comment above the 'times' function. Rather than printing "hello" 3 times, the example actually prints: 0 hello 1 hello 2 hello Furthermore, in the code wouldn't it be more straightforward to use this.valueOf() rather than Number(this) since we're already dealing with a Number object?

Note from the Author or Editor:
Change comment to: // n.times(function(n) { console.log("hello"); }); and code to: var n = this.valueOf();

David Sletten  Jan 20, 2013  Aug 29, 2014
Printed
Page 212
Top and bottom of page

The explanation of the type() function hints that it uses the getName() function from pg. 209. However, the version on pg. 212 differs from the one on pg. 209. In particular, the new version actually creates a 'name' property on the Function objects it examines. This new behavior should be highlighted.

Note from the Author or Editor:
Add sentence: "The code for that function and method are included here for simplicity. The Function.getName() method has been modified to create a name property on the Function objects it examines."

David Sletten  Jan 21, 2013  Aug 29, 2014
Printed
Page 216
Middle of page

A number of example functions in the text do not conform to JavaScript naming conventions. On pg. 216, the foreach() method defined for Set objects contrasts with the forEach() method of Array objects. The same is true on pg. 201 with the foreach() method of Range objects. Likewise, pg. 136 and 212 define a classof() function. However, based on the example of the valueOf() method of Object instances, it seems that the function should be named classOf() instead.

Note from the Author or Editor:
Corrected forEach; classof seems to be in the same group as typeof and instanceof., but since it is a method and not a keyword, it will change also.

David Sletten  Feb 02, 2013  Aug 29, 2014
PDF
Page 216
right on top

// For any object, return a string. This function will return a different // string for different objects, and will always return the same string // if called multiple times for the same object. To do this it creates a // property on o. In ES5 the property would be nonenumerable and read-only. function objectId(o) { var prop = "|**objectid**|"; // Private property name for storing ids if (!o.hasOwnProperty(prop)) // If the object has no id o[prop] = Set._v2s.next++; // Assign it the next available return o[prop]; // Return the id } Obviously, this code doesn't create a property that's nonenumerable and read-only, it creates a regular one. That's so obvious that maybe the author meant something else when saying that, like that he would write a specific property creation code that would add a nonenumerable and read-only property in case he was gonna use the ES5 features.

Note from the Author or Editor:
Amend comment for clarity: // For any object, return a string. This function will return a different // string for different objects, and will always return the same string // if called multiple times for the same object. To do this it creates a // property on o. In ES5 you would use Object.defineProperty() to // make the property nonenumerable and read-only.

Anonymous  Aug 27, 2013  Aug 29, 2014
Printed
Page 218
Top of page

The for/in loop neglects to declare the variable 'name' with 'var'. 'name' becomes a global variable.

Note from the Author or Editor:
change loop to read: for(var name in namesToValues) {

David Sletten  Feb 16, 2013  Aug 29, 2014
Printed
Page 226
1st paragraph

At the end of the first sentence: "...allowing access to that state only through the methods of the object, and NOW allowing the important state variables to be read or written directly." I believe that NOW should be NOT: "...and NOT allowing the important state variables to be read or written directly."

Note from the Author or Editor:
Change "now" to "not" as per detailed description: "...allowing access to that state only through the methods of the object, and not allowing the important state variables to be read or written directly."

Daniel Pfeiffer  Aug 13, 2011  Aug 29, 2014
Printed
Page 232
Middle of page

The add() methods for both Set and NonNullSet each return a this reference in order to support method chaining. However, the add() method of sets created by means of filteredSetSubclass() does not.

Note from the Author or Editor:
Change code to read: return superclass.prototype.add.apply(this, arguments);

David Sletten  Feb 25, 2013  Aug 29, 2014
Printed
Page 233
Middle of page

In the example using composition to define FilteredSet there is no point in naming the constructor function object (the first argument to Set.extend()). The name is not used anywhere and may lead to confusion when juxtaposed with the variable to which the return value of Set.extend() is assigned. Furthermore, the parallels with NonNullSet on the previous page are clearer if an anonymous constructor is used.

Note from the Author or Editor:
Change code to: var FilteredSet = Set.extend( function(set, filter) { // The constructor

David Sletten  Feb 26, 2013  Aug 29, 2014
PDF
Page 234
last code fragment before 9.7.4

var t = new FilteredSet(s, { function(x} { return !(x instanceof Set); }); should it be as following? var t = new FilteredSet(s, function(x) {return !(x instanceof Set); });

Note from the Author or Editor:
Change function(x} to function(x)

Anonymous  Aug 12, 2011  Aug 29, 2014
Printed
Page 238
Example 9-17

Example 9-17 throws an Error by simply invoking the Error() function. This is inconsistent with the 3 instances in Example 9-16 (and elsewhere) that invoke Error() as a constructor via the 'new' operator. While both uses are equivalent in this case, the result can be (dramatically) different with other constructors. Also the idGetter() function definition ends with an extraneous semicolon.

Note from the Author or Editor:
Change code to read: throw new Error("Can't define id for nonextensible objects");

David Sletten  Mar 09, 2013  Aug 29, 2014
PDF
Page 240
Example 9-19 implementation of freezeProps and hideProps

The following statement causes getOwnPropertyDescriptor to throw a TypeError when it returns "undefined". if (!Object.getOwnPropertyDescriptor(o,n).configurable) return; ex. freezeProps({x:1, y:2}, "y", "z"); // => TypeError hideProps({x:1, y:2}, "y", "z"); // => TypeError Shouldn't it be check the value of the property "n" exist or not? ie. if (o.hasOwnProperty(n) && !Object.getOwnPropertyDescriptor(o,n).configurable) return;

Note from the Author or Editor:
Change code to: if (o.hasOwnProperty(n) && !Object.getOwnPropertyDescriptor(o,n).configurable) return; in both functions, as described in erratum.

HIROKI OGASAWARA  Oct 25, 2011  Aug 29, 2014
Printed
Page 240
Top of page

In example 9-19, the functions freezeProps() and hideProps() use the technique Array.prototype.splice.call(arguments, 1) to extract all arguments passed to the function, aside from the first, into an array. It doesn't really matter in these functions, but in general it's probably advisable to use slice() rather than splice(), so that the arguments object is not modified.

Note from the Author or Editor:
Change Array.prototype.splice.call(arguments, 1); to Array.prototype.slice.call(arguments, 1);

David Sletten  Mar 10, 2013  Aug 29, 2014
Printed
Page 243
Middle of page

In Example 9-22, the function which defines the size property has a stray parameter 'x' that is neither used nor needed.

Note from the Author or Editor:
Change line to read: size: { value: function() { return this.n; } },

David Sletten  Mar 14, 2013  Aug 29, 2014
Other Digital Version
246
First paragraph of Modules section

ECMAScript 5 reserves the keywords "import" and "export" not the keywords "imports" and "exports".

Note from the Author or Editor:
Make correction as specified in description.

Evan  Sep 29, 2011  Aug 29, 2014
Printed
Page 266
4th paragraph

"It defines functions using function definition expressions only and does not include the function definition statement." There is no "function definition statement", but should be "function declaration statement", according to chapter 8.

Note from the Author or Editor:
Change as per detailed description of error.

Rong Zeng  Mar 02, 2012  Aug 29, 2014
Printed
Page 267
7th paragraph

Last sentence of 7th paragraph reads "Others whitelist a specific set of properties know to be safe." Probably should read "Others whitelist a specific set of properties known to be safe."

Note from the Author or Editor:
Change as per detailed description.

Joel E Merritt  Sep 30, 2013  Aug 29, 2014
Printed
Page 270
JavaScript version number

Should "ten" be replaced by "one hundred"? The text reads: "version number times ten. Pass 170 to select JavaScript 1.7"

Note from the Author or Editor:
Replace "version number times ten." with "version number times 100." (Numbers greater than ten are written using digits per O'Reilly Style guide.)

Saašha Metsärantala  Dec 29, 2011  Aug 29, 2014
Printed
Page 270
fourth to las line

variable is shadowing A NEW variable by the same name: "A NEW" should read "AN OLD".

Note from the Author or Editor:
Change text from: This matters only when the new variable is shadowing a new variable by the same name: to: This matters only when the new variable is shadowing an old variable by the same name:

Lutz Adam  Jan 21, 2012  Aug 29, 2014
Printed
Page 274
1st paragraph of section 11.4.2

"JavaScript 1.7's for/in loop is more like Python's for/in and allows it iterate over any iterable object." probably should read "JavaScript 1.7's for/in loop is more like Python's for/in and allows it to iterate over any iterable object."

Note from the Author or Editor:
Change words: "...and allows it iterate over any..." to "... and allows it to iterate over any..." (add word "to")

Joel E Merritt  Oct 01, 2013  Aug 29, 2014
Printed
Page 285
5th code fragment

// This is yet another way to get a list of all <name> tags. var names3 = pt.element.*; probably should be // This is yet another way to get a list of all <name> tags. var names3 = pt.element.*;

Note from the Author or Editor:
Add line break after "tags."

Joel E Merritt  Oct 01, 2013  Aug 29, 2014
Printed
Page 291
1st paragraph - "As you see..."

( sixth Edition - 12.1 Scripting Java with Rhino | 291 ) path in source code -> "/tmp/test" path in text below -> "/type/test/"

Note from the Author or Editor:
Change as in description: /type/test becomes /tmp/test

Dirk Zoettl  Jul 26, 2013  Aug 29, 2014
Printed
Page 291
3rd text paragraph (not counting code examples)

the JavaScript string "/type/test" is automatically converted should probably read the JavaScript string "/tmp/test" is automatically converted

Note from the Author or Editor:
Change "/type/test" to "/tmp/test" as per description of error.

Joel E Merritt  Oct 01, 2013  Aug 29, 2014
Printed
Page 308
fourth to last paragraph

// Explicitly alter the presentation of the HEADING element "HEADING" should read "TIMESTAMP".

Note from the Author or Editor:
Change // Explicitly alter the presentation of the heading element to // Explicitly alter the presentation of the element (We don't know what kind of element had the id="timestamp")

Lutz Adam  Jan 21, 2012  Aug 29, 2014
Printed
Page 309
Example 13.1

Hello! In example 13.1, the JavaScript program loops through elements of the class "reveal". In this example, there is only ONE such element, though. I assume that the aim is that this program should work fine even if the dom contains several elements of this class, otherwise, you would not need to loop through them all. But, if you add elements of the class "reveal", it will not work: No matter on which of these elements you click, only the last one will be toggled. This problem is exactly what Douglas Crockford explains on page 39 in "The good parts". Regards! Saašha,

Note from the Author or Editor:
This is an embarassing bug, that is explained on page 185 of the book. Please change JavaScript code in the example to the code shown here: https://github.com/davidflanagan/javascript6_examples/blob/master/examples/13.01.reveal.html

Saašha Metsärantala  Dec 31, 2011  Aug 29, 2014
Printed
Page 312
second code snippet

Mr.Flanagan wrote that when XML is being used, the actual code in a <script> tag should be enclosed within the tags <![CDATA[ ... ]]>. He meant to write <!--[CDATA[ ... ]] -->. But even the corrected version works only in IE8. The corrected version makes the JavaScript invisible to FireFox (at this site, Mozilla/5.0 (Windows NT 5.1; rv:10.0) Gecko/20100101 Firefox/10.0).

Note from the Author or Editor:
Change example to: <script> // <![CDATA[ // Your JavaScript code goes here // ]]> </script>

Thomas Paulick  May 26, 2012  Aug 29, 2014
PDF
Page 337
3rd paragraph from the bottom

Just a minor formatting issue. In the sentence "...without altering nonexecutable HTML.toStaticHTML() is not standardized..." there is a line break in the middle of "HTML.toStaticHTML()". I believe it was done unintentionally.

Note from the Author or Editor:
Take out blanks in "a more nuanced toStatic HTML() " and add a <phrase> in markup to keep the next toStaticHTML() together.

Mikhail Kalenkov  Oct 02, 2011  Aug 29, 2014
Printed
Page 342
Example 14-1

I found that the code for the timer utility function "invoke" works as shown in IE9, Chrome and Safari, but Firefox 10.0.2 throws an error message "repeat is not defined" when using all four arguments. I think this is because the function repeat is defined within an else clause. According to page 91 (penultimate para) of the book, this is not allowed (or at least not portable). The error went away when I moved the function definition below the closing curly bracket of the else.

Note from the Author or Editor:
Moved the repeat function below the closing brace of the "else" clause, as in the description of error.

None  Mar 07, 2012  Aug 29, 2014
PDF
Page 343
3rd paragraph, section 14.2 Browser location and Navigation

The book states: "The Document object also has a URL property, which is a static string that holds the URL of the document when it was first loaded. If you navigate to fragment identifiers (like #table-of-contents) within the document, the Location object is updated to reflect this, but the document.URL property remains unchanged." This is untrue, document.URL is same as location.href, it does change to reflect the fragment identifier.

Note from the Author or Editor:
Change text to read: If you navigate to fragment identifiers (like #table-of-contents) within the document, both the Location object and the document.URL property are updated to reflect this.

Anonymous  Aug 25, 2012  Aug 29, 2014
Printed
Page 345
end of section14.3

The book states that the code location.search = "?page=" + (pagenum+1); loads the next page. In reality, it only reloads the same page with the new query string that was written above.

Note from the Author or Editor:
Change line to read: location.search = "?sold=" + (sold+1); // reload page with new query string (changed from "page" to "sold" to avoid confusion with prevoius example)

Thomas Paulick  May 31, 2012  Aug 29, 2014
Printed
Page 350
near top of code sample

The statement for displaying the modal dialog box is written: var p = showModalDialog("multiprompt.htm", ['Enter 3D point coordinates','x','y','z'], "dialogwidth:400; dialogheight:300; resizable:yes"); Firefox displays the modal dialog correctly with this statement, but IE8 requires units for the height and width of the dialog: var p = showModalDialog("multiprompt.htm", ['Enter 3D point coordinates','x','y','z'], "dialogwidth:400px; dialogheight:300px; resizable:yes"); Also, the IE JavaScript safety wall prevents the "Okay" and "Close" buttons from working correctly.

Note from the Author or Editor:
Add px to the dimensions as described in error: var p = showModalDialog("multiprompt.html", ["Enter 3D point coordinates", "x", "y", "z"], "dialogwidth:400px; dialogheight:300px; resizable:yes");

Thomas Paulick  May 31, 2012  Aug 29, 2014
Printed
Page 351
14.7 first paragraph

"... and whose name is the HTMLElement ..." should read: and whose value is the HTMLElement

Note from the Author or Editor:
yes, make that change.

None  May 27, 2011  Aug 12, 2011
PDF
Page 362
html example code

<html> <head> <title>Sample Document</title> </head> <body> <h1>An HTML Document</h1> <p>This is a <i>simple</i> document. </html> </body> tag missing in above code

Note from the Author or Editor:
Add </body> tag before closing </html> tag.

zziuni  Aug 19, 2011  Aug 29, 2014
PDF
Page 367
3rd paragraph

HTMLDocument's scripts propertys description printed.... <scripts> property is standardized by HTML5 to be an HTMLCollection of <script> elements, but it is not, at the time of this writing, universally implemented. is scripts property is standardized by HTML5 to be an HTMLCollection of <script> elements, but it is not, at the time of this writing, universally implemented.

Note from the Author or Editor:
Eliminate angle brackets from <scripts> property as per detailed description.

zziuni  Aug 19, 2011  Aug 29, 2014
Printed
Page 368
section 15.2.4, first sentence

The sentence starts with "The class attribute of an HTML is ..." The word 'element' is missing from after 'HTML', i.e. should read "The class attribute of an HTML element is ..."

Note from the Author or Editor:
Add "element" after "HTML", as in detailed description of error.

Alan Rew  Mar 29, 2012  Aug 29, 2014
Printed
Page 369
Section 15.2.5, 3rd paragraph

'Any <span> with "warning" and "fatal" in its class' shoud read 'Any <span> with "fatal" and "error" in its class'

Ken Wilson  Aug 01, 2011  Aug 12, 2011
PDF
Page 375
15.4.1section first paragraph

HTMLElement defines properties for the universal HTTP attributes such as id, title lang, and dir, and event handler properties like onclick. maybe.. HTTP attributes is HTML attributes ?

Note from the Author or Editor:
Change HTTP to HTML, as per detailed description, and also add comma after "title".

zziuni  Aug 28, 2011  Aug 29, 2014
Printed
Page 378
example in 2nd para

ymin assigned twice, second time must be: ymax=parseFloat(...); Following line (assigning points) must be removed, because points not used any further and "data-points" not in HTML.

Note from the Author or Editor:
Code should read: var ymax = parseFloat(elt.getAttribute("data-ymax")); and remove the line starting "var points "

Paul E.S. Wormer  Nov 24, 2011  Aug 29, 2014
Printed
Page 379
6th paragraph, first sentence.

The sentence refers to the insertAdjacentHTML() method as: insert Adjacent HTML() The spaces should be removed.

Note from the Author or Editor:
Remove spaces as per detailed description.

Scott Marcus  Dec 02, 2011  Aug 29, 2014
Printed, PDF
Page 382
section 15.6.1

The API name createElement() is split over 2 lines The API name createComment() is also split over 2 lines.

Note from the Author or Editor:
Remove extra spaces in docbook source

Alan Rew  May 10, 2012  Aug 29, 2014
Printed
Page 383
example 15.4

When I take the table from: http://www.w3schools.com/html/tryit.asp?filename=tryhtml_table_cellspacing and use FF 8, I get the error "cell1 undefined". The problem is that the first row does not contain <td> elements but <th> elements. Solution is: rows = Array.prototype.slice.call(rows,1); // Snapshot in a true array instead of rows = Array.prototype.slice.call(rows,0); // Snapshot in a true array

Note from the Author or Editor:
Change as per detailed description of error.

Paul E.S. Wormer  Nov 26, 2011  Aug 29, 2014
Printed, PDF
Page 394
5th and 8th paragraphs

In the 5th paragraph, the API name scrollIntoView() is split over 2 lines. In the 8th paragraph, the property name offsetParent is split over 2 lines. Splitting API and property names reduces readability unnecessarily.

Note from the Author or Editor:
Add <phrase> to source markup to keep on one line.

Alan Rew  May 10, 2012  Aug 29, 2014
Printed, PDF
Page 396
2nd paragraph from bottom of page

The API name getBoundingClientRect() has spaces inserted into its name, when used in the 3rd and 4th lines of the paragraph. In the first case, it's written as getBoundingClient Rect() and in the second case getBounding ClientRect() The name is also split across 2 lines in both places, which should be avoided if possible for readability.

Note from the Author or Editor:
Eliminate spaces in the source docbook.

Alan Rew  Apr 02, 2012  Aug 29, 2014
Printed, PDF
Page 398
table at top of page, for input type=text

In the table entry for <input type="text"> the 'Description and events' column says "... the default <input> element it type attribute is ..." The word 'it' should be replaced with 'if'

Note from the Author or Editor:
Change as per detailed description: single-line text entry field; the default <input> element if type attribute is omitted or unrecognized.

Alan Rew  May 10, 2012  Aug 29, 2014
Printed
Page 398
8th entry in table

For "<input> element it type attribute" read "<input> element if type attribute".

Martin Leese  Dec 30, 2012  Aug 29, 2014
Printed
Page 405
8th paragraph headed "title"

For "<title> and <title>" read "<title> and </title>".

Note from the Author or Editor:
As per detailed description, change second "<title>" to "</title>"

Martin Leese  Dec 30, 2012  Aug 29, 2014
PDF
Page 406
15.10.2 example code

end of script in the example code: document.write("<br>Accessed on: " + new Date()); should end with closing tag. document.write("<br>Accessed on: " + new Date() + "</p>"); Browsers append </p> automatically though, we should not rely on such behavior.

Note from the Author or Editor:
Change as specified in description of error:

iwanaga  Sep 06, 2012  Aug 29, 2014
PDF
Page 416
16.1.4, 2nd sentence, 1st paragraph

Firefox CSS extensions are prefixed with "-moz-" Therefore, the beginning: Firefox uses moz-, ... has to be corrected as: Firefox uses -moz-, ... https://developer.mozilla.org/en-US/docs/CSS/CSS_Reference/Mozilla_Extensions

iwanaga  Oct 29, 2012  Aug 29, 2014
Printed
Page 436
1st example, after 2nd paragraph

The example that reads: var title = document.getElementById("sectiontitle"); var titlestyles = window.getComputedStyle(element, null); should read: var title = document.getElementById("sectiontitle"); var titlestyles = window.getComputedStyle(title, null);

Note from the Author or Editor:
Change code to read as in description of error.

None  Aug 20, 2011  Aug 29, 2014
Printed
Page 447
5th paragraph

"how to work with a specific types of events." should read "how to work with specific types of events." or "how to work with a specific type of events."

Note from the Author or Editor:
Change sentence to read: "The chapter ends with a series of examples that demonstrate how to work with specific types of events."

Joel E Merritt  Oct 20, 2013  Aug 29, 2014
Printed, PDF
Page 459
middle of page

middle of the page: removeEventListener() There is a space between 'remove' and 'Event', which is definitely a mistake.

Note from the Author or Editor:
Remove spaces in docbook source.

Anonymous  Dec 13, 2011  Aug 29, 2014
Printed, PDF
Page 463
3rd paragraph from bottom of page

The API 'addEventListener' is split up into 3 words i.e. "add Event Listener()" near the end of the paragraph.

Note from the Author or Editor:
Removed spaces from docbook source.

Alan Rew  Apr 02, 2012  Aug 29, 2014
PDF
Page 463
2nd paragraph of Section 17.3.6

Replace "an" with "a": You might register an change handler on a <form> element, ... => You might register a change handler on a <form> element, ...

Note from the Author or Editor:
Replace as specified in detailed description.

Anonymous  Nov 29, 2013  Aug 29, 2014
Printed
Page 471
4th paragraph, opening sentence

Text says "In Firefox you can the nonstandard ...". Should it read "In Firefox you use the nonstandard ..."?

Ken Wilson  Aug 03, 2011  Aug 29, 2014
Printed
Page 473
second last line

There is a missing 'e' in the second 'framewidth': framewidth = Math.min(framwidth, contentwidth); // content should be: framewidth = Math.min(framewidth, contentwidth); // content

Note from the Author or Editor:
Change "framwidth" to "framewidth" as specified in detailed description.

Anonymous  Jan 13, 2012  Aug 29, 2014
Printed
Page 496
3rd paragraph

2nd sentence states that the URL in open() is relative to the URL of the document that contains the script that is calling open(). Need to add to this sentence, "... unless the document contains a <base> tag, in which case the URL is relative to that." Note that some older browsers (eg, Netscape 7.02) do not respect this.

Note from the Author or Editor:
Add text to sentence as per description: , unless the document contains a <base> tag, in which case the URL is relative to that. (Some very old browsers, e.g., Netscape 7.02, do not respect this.)

Martin Leese  Dec 30, 2012  Aug 29, 2014
Printed
Page 498
second bullet point

The space between 'Response' and 'Headers' should be removed, i.e. the API is getAllResponseHeaders()

Note from the Author or Editor:
Remove spaces as per description

Alan Rew  Mar 29, 2012  Aug 29, 2014
Printed
Page 499
Example 18-2

Comment is "If the request was compete and successful". Should read "If the request was complete and successful".

Ken Wilson  Aug 03, 2011  Aug 29, 2014
Printed, PDF
Page 501
last paragraph, penultimate line

The text refers to the non-existent XMLHttpRequest method setOverrideMimeType(), instead of overrideMimeType(), which is probably what is intended.

Note from the Author or Editor:
Change setOverrideMimeType() to overrideMimeType()

Alan Rew  Apr 06, 2012  Aug 29, 2014
Safari Books Online
501
Example 18-3

Comment "If the request was compete and successful" should be "If the request was complete and successful".

Andrew Hinton
Andrew Hinton
O'Reilly Author 
Jan 22, 2013  Aug 29, 2014
Printed
Page 502
Example 18-4

Page 503; Example 18-5, first paragraph following: "HTML forms generate POST requests by default." Is that true? Perhaps XMLHTTPRequest does, but do HTML forms default to POST? Page 502 and 503: Example 18-4: encodeFormData() function. I believe there are other locations where this procedure is used (decoding data, etc.). The code indicates that to *encode* data, first replace spaces with "+" then encodeURIComponent. To *decode* submitted data, first decodeURIComponent and then replace "+" with space (I am *sure* I saw that decoding somewhere, using 'unescape' - but it seems to be wrong). Done that way, spaces and "+"s in the original text are mixed and cannot be unmixed. encodeURIComponent appears *not* to act precisely the way a form submission acts in encoding items. In submission of a real form on an HTML page, submitted data first has "+"s encoded (HEXed/escaped) but SPACES ARE LEFT ALONE (not escaped). After that step (escaping) spaces are converted to "+" as the final encoding step. Apparently this is a hold over from old formats when only plain text (no "+"s!) with spaces was expected (if that is the case, then just convert spaces to + to send it without problems and there is no mixing of "+" and space as the original text had no "+"s). That is the data (first escape some characters, including "+" but EXCLUDING spaces, and then change spaces to "+"). I guess, if done now, both "+" and spaces would simply be escaped. On the other hand, encodeURIComponent seems to escape both spaces AND "+" - a bit different from www-form encoding (in which case don't do any of the space/+ conversions in creating data, there won't be any problem or spaces or "+" after endodeURIComponent). Hopefully servers will handle decoding of submitted data (they will try first to convert "+" to space, but find none, and then unescape the result ... and it comes out right). On the other hand, I am sure there is code in 'Javascript, The Definitive Guide" for DECODING responses and if the response is sent back 'www-form-encoded' one has to decode it properly (first change "+" to space and *then* unescape which will recover any "+"s in the original data).

Note from the Author or Editor:
In the first block of code on page 503, change these lines: name = encodeURIComponent(name.replace(" ", "+")); // Encode name value = encodeURIComponent(value.replace(" ", "+")); // Encode value To: name = encodeURIComponent(name).replace("%20", "+"); // Encode name value = encodeURIComponent(value).replace("%20", "+"); // Encode value In the last paragraph of page 503, cut the lines: HTML forms generate POST requests by default, but they can also make GET requests. (When the purpose...than POST.) And replace them with these: Form data can also be submitted using a GET request, and when the purpose of a form submission is to make a read-only query, GET is more appropriate than POST.

Anonymous  Jul 11, 2011  Aug 12, 2011
ePub
Page 507
Fifth paragraph

The text "clear Interval()" has an extra space and should be "clearInterval()", in the following text: "passed to clear Interval() to cancel any future invocations"

Note from the Author or Editor:
Space removed as per detailed description.

Carlos Cortes  Apr 11, 2013  Aug 29, 2014
Printed
Page 508
First line

The word 'to' should be inserted between the words 'object' and 'register'. i.e. the sentence should read "You can call the addEventListener() method of the XMLHttpRequest object to register handlers..."

Note from the Author or Editor:
Add "to" so that phrase reads "...of the XMLHttpRequest object to register handlers..."

Alan Rew  Mar 29, 2012  Aug 29, 2014
Printed
Page 515
above "appendChild(script)" in the code

It could be worth noting, as a comment in the JavaScript code, that the line appending the script node should be preceded by setAttribute('type', 'text/javascript') when the the JavaScript code is to be used together with XHTML code.

Note from the Author or Editor:
Added this comment: // If you use the JavaScript code together with XHTML, add // script.setAttribute('type', 'text/javascript');

Saašha Metsärantala  Dec 29, 2011  Aug 29, 2014
Printed
Page 554
1st paragraph

As is stated in the penultimate para of the same page, the font-size property name should be quoted, ie "font-size": 10 instead of font-size: 10

Note from the Author or Editor:
Change as described in error: "font-size": 10

None  Mar 13, 2012  Aug 29, 2014
Printed
Page 559
Code sample before last paragraph

The code sample at the end of page 559 is written as: $('#temp').load("us_weather_report.html", {zipcode:02134, units: 'F'}); This will not achieve the proper effect (and will be rejected in strict mode), because the zip code has a leading 0 and will be converted to octal in most implementations - as page 32 states, "you should never write an integer literal with a leading zero". The zip code should be enclosed in quotation marks: $('#temp').load("us_weather_report.html", {zipcode:'02134', units: 'F'});

Note from the Author or Editor:
Enclose occurrences of 02134 in single quotes, as in detailed description.

Joshua Davies  Feb 04, 2014  Aug 29, 2014
Printed
Page 562
first example

this.disabled = "disabled" should be this.disabled = true or this.setAttribute("disabled", "disabled")

Note from the Author or Editor:
The reporter is correct. Please change this line to: this.disabled = true;

Anonymous  Nov 03, 2012  Aug 29, 2014
Printed
Page 577
middle of page, following first actual paragraph

In the example: p:nth-child(3n+1):text(JavaScript):not(:has(a)) shouldn't "text" be "contains"? "text" searches for [type="text"] while "contains" searches for its textual argument.

Note from the Author or Editor:
Replace p:nth-child(3n+1):text(JavaScript):not(:has(a)) with: p:nth-child(3n+1):contains(JavaScript):not(:has(a))

James Finn  May 03, 2012  Aug 29, 2014
Printed
Page 600
2nd line

Second line says "memory.setAtttribute". It should be "memory.setAttribute", with only two t's.

Note from the Author or Editor:
Change as per description; memory.setAtttribute becomes memory.setAttribute

Domen  Mar 11, 2012  Aug 29, 2014
PDF
Page 641
1st paragraph

The description of the function rotateAbout should be counterclockwise, not clockwise. We can write a code fragment to validate it, for example: <canvas id="my_canvas_id" width=1000 height=1000></canvas> <script> var canvas = $('#my_canvas_id')[0]; var c = canvas.getContext('2d'); function rotateAbout(c, theta, x, y) { var ct = Math.cos(theta), st = Math.sin(theta); c.transform(ct, -st, st, ct, -x*ct-y*st+x, x*st-y*ct+y); /* equal to c.translate(x, y); c.rotate(theta); c.translate(-x, -y); */ } rotateAbout(c, Math.PI, 500, 500); c.beginPath(); c.moveTo(300, 300); c.lineTo(200, 200); c.lineTo(100, 200); c.stroke(); </script> original paragraph: // Rotate theta radians clockwise around the point (x,y) // This can also be accomplished with a translate,rotate,translate sequence function rotateAbout(c,theta,x,y) { var ct = Math.cos(theta), st = Math.sin(theta); c.transform(ct, -st, st, ct, -x*ct-y*st+x, x*st-y*ct+y); }

Note from the Author or Editor:
Change comment to read "counterclockwise" as per detailed description.

Pang Luo  Nov 18, 2013  Aug 29, 2014
Printed
Page 670
second to last line on the page

The next to last line reads: elt.innerHTMl = "Geolocation not supported in this browser"; It should read: elt.innerHTML = "Geolocation not supported in this browser"; (The 'L' in "HTML" should be capitalized).

Note from the Author or Editor:
As per description, change innerHTMl to innerHTML

Joshua Davies  Feb 14, 2014  Aug 29, 2014
Printed
Page 674
starting comments in the code for 'display(state)'

... // initial state, in that case we would overwrite the acutal[SIC] historical (acutal -> actual) and ... (as an aside) 'is different from' differs from 'is different than.'

Note from the Author or Editor:
yes, fix the typo

Anonymous  Jul 16, 2011  Aug 12, 2011
Printed
Page 689
3rd code block

the line: var last3 = ints.subaaray(ints.length-3, ints.length); // Last 3 of them should read: var last3 = ints.subaray(ints.length-3, ints.length); // Last 3 of them

Note from the Author or Editor:
Change subaarray to subarray

Anonymous  Jan 18, 2012  Aug 29, 2014
Printed
Page 700
10th line of first example

In the 10th line of example there is comma missing after } (after third parameter of requestFileSystem).

Note from the Author or Editor:
Change these two lines: // Use fs here } To add a comma after the brace: // Use fs here },

Anonymous  Jul 06, 2011  Aug 12, 2011
PDF
Page 725
last part, Synopsis of Array.filter()

array.map(predicate) array.map(predicate, o) should be array.filter(predicate) array.filter(predicate, o)

Note from the Author or Editor:
Change as per detailed description.

Shoko Shikano  Sep 25, 2011  Aug 29, 2014
PDF
Page 736
Examples for Array.some()

The comment on this example does not seem to match the code: [1,2,3].some(function(x) { return x > 2; }) // => true: some elts are > 3 I think the last digit in the comment should be changed thus: [1,2,3].some(function(x) { return x > 2; }) // => true: some elts are > 2 (This is a darn good book, otherwise)

Note from the Author or Editor:
Change as per description of error; comment should read "some elts are > 2"

Bruce Wisentaner  Mar 05, 2013  Aug 29, 2014
Printed
Page 738
Example

The examples of array.splice() give false return results. It should be: var a= [1,2,3,4,5,6,7,8]; a.splice(1,2); // Returns [2,3]; a is [1,4,5,6,7,8] a.splice(1,1); // Returns [4]; a is 1,5,6,7,8] a.splice(1,0,2,3) //Returns []; a= 1,2,3,5,6,7,8

Note from the Author or Editor:
Add this as the first example: a.splice(4); // Returns [5,6,7,8]; a is [1,2,3,4] Then all the subsequent examples are correct.

Anonymous  Nov 07, 2011  Aug 29, 2014
Printed, PDF
Page 787
sample JSON.parse() code after 4th paragraph

The code sample starts with the line var data JSON.parse(text, function(name, value) { There should be an equals '=' sign between 'data' and 'JSON', i.e. var data = JSON.parse(text, function(name, value) {

Note from the Author or Editor:
Change as per description; add an equal sign after "data"

Alan Rew  Apr 04, 2012  Aug 29, 2014
Printed
Page 802
last code sample of the Number entry

The last code sample for Number reads: var value = 1234; var binary_value = n.toString(2); "n" is not defined in this example; assuming that it's meant to be a demonstration of the "toString" function, it should read: var value = 1234; var binary_value = value.toString(2); instead.

Note from the Author or Editor:
Make change as per description; change from var binary_value = n.toString(2); to var binary_value = value.toString(2);

Joshua Davies  Feb 25, 2014  Aug 29, 2014
PDF
Page 814
Part 3, Core JavaScript Reference, 2nd paragraph in Description part of Object.defineProperty()

The last sentence says that the default attribute values of absent members are false or null, but ECMAScript language defines them false or "undefined", not null. This definition is shown as Table-7 on ECMA-262 edition 5.1, within the Object Type section (8.6.1 actually).

Note from the Author or Editor:
Change "false or null" to "false or undefined"

Shoko Abe  Jul 20, 2011  Aug 12, 2011
Printed
Page 845
4th line

Text to the left of the matched substring is $`, not $'.

Note from the Author or Editor:
Change first column in the row with "The text to the left of the matched substring" to $`

James Finn  May 21, 2012  Aug 29, 2014
, Printed
Page 876
3rd paragraph of "fillText" entry

In the sentence starting "If the textBaseline is 'center' . . . " should read "If the textBaseline is 'middle' . . . " . Page 873 says that there is no 'center' as a legal value of textBaseline.

Note from the Author or Editor:
Change "center" to "middle" as per description of error.

Thomas Giammo  Jul 20, 2013  Aug 29, 2014
Printed
Page 880
Last text paragraph on the page

The last sentence of the summary for ClientRect reads: ClientRect objects are x static: The 'x' appears to be a typo (if not, it isn't explained).

Note from the Author or Editor:
Change "x static" to "static" (delete the "x")

Joshua Davies  Mar 04, 2014  Aug 29, 2014
Printed, PDF
Page 898
last paragraph in 'DocumentFragment'

The API name querySelectorAll() has 2 spaces inserted into its name, i.e. written as 'query selector All()'. Might be due to spell-checker auto-correct being used unguardedly, which can be hazardous in a technical book.

Note from the Author or Editor:
Remove spaces in querySelectorAll() as per description.

Alan Rew  May 10, 2012  Aug 29, 2014
Printed
Page 898
Last paragraph in the entry for Document

The last sentence of the last paragraph ends with: since there is an onDOMContentLoaded property This sentence should read: since there is no onDOMContentLoaded property

Note from the Author or Editor:
"there is an onDOMContentLoaded property" should be changed to "there is no onDOMContentLoaded property" as described in error.

Joshua Davies  Mar 05, 2014  Aug 29, 2014
Printed
Page 922
explanation of dispatchEvent(Event event)

At least in 'WebKit' you need to call document.createEvent('Events') to create a simple event object (the book states that document.createEvent('event') will do).

Note from the Author or Editor:
Please fix.

Axel Schreiner  Aug 06, 2011  Aug 12, 2011
Printed
Page 938
Last Paragraph

On the methods of HTMLOptionsCollection, there is the "add" method. It says that the second parameter is optional. This is not true in all browsers. In FireFox (tested on 3.6.18, 4.0 and 5.0.1), the 2nd argument is REQUIRED. You must pass null if you want to add at the end. Here is the message that Firefox shows: Error: uncaught exception: [Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "..." data: no] The same problem happens on page 987, on the add method. If the specs/RFC (if any) define that the 2nd parameter is indeed optional, there should be a note on the book saying that Firefox is buggy. If the specs/RFC define that the 2nd parameter is mandatory, the book should be corrected. Thanks, Claudio Neves

Note from the Author or Editor:
Add text at end of paragraph: In some older browsers such as Firefox 5.0.1, the second argument is required.

Claudio Neves  Aug 04, 2011  Aug 29, 2014
Other Digital Version
943
Description of min property of Input

The min property is described as "A maximum valid value for this Input element." This should probably say "A minimum valid ..."

Note from the Author or Editor:
Make change as in description of error: "A maximum valid value for this input. element." should become "A minimum valid value for this input. element.

Evan  Dec 15, 2011  Aug 29, 2014
PDF
Page 964
"Properties" list, items 2 & 3

The examples given for the "host" and "hostname" location properties erroneously include the URI schema (erroneously referred to as the "protocol" by JavaScript). The hostname property includes only of the name, domain-name and top-level domain of the host. The host includes the hostname and port number (if other than the default for the protocol indicated by the scheme). So... "http://www.oreilly.com:1234" should be "www.oreilly.com:1234" and "http://www.oreilly.com" should be "www.oreilly.com"

Note from the Author or Editor:
Change as per description: "http://www.oreilly.com:1234" should be "www.oreilly.com:1234" and "http://www.oreilly.com" should be "www.oreilly.com"

Dave Livesay  Feb 28, 2013  Aug 29, 2014
Printed
Page 983
First sentence on page

The first sentence reads: When the amount of work or time required to complete the task is not know, It should read: When the amount of work or time required to complete the task is not known,

Note from the Author or Editor:
Change "know" to "known"

Joshua Davies  Mar 20, 2014  Aug 29, 2014
Printed, PDF
Page 1018
1st paragraph, line 4

The onreadystatechange property is printed with an embedded space: onready statechange

Note from the Author or Editor:
Blanks removed from source.

Alan Rew  Apr 05, 2012  Aug 29, 2014
Printed, PDF
Page 1021
left column, line 13.

// and / */ in comments, 23 should read // and /* */ in comments, 23

Note from the Author or Editor:
Please fix.

Mingway Huang  Jul 31, 2011  Aug 12, 2011
Printed, PDF
Page 1026
right column, line 2 from the bottom

"till or stroke using, 647" should read: "fill or stroke using, 647"

Note from the Author or Editor:
Please fix it.

Mingway Huang  Aug 01, 2011  Aug 12, 2011
Printed, PDF
Page 1061
index entry for __proto__

The index entry for __proto__ is wrong, out by 1 page. Reads 136 Should be 135

Alan Rew  May 10, 2012  Aug 29, 2014
Other Digital Version
2018
The page number above is the location number of Kindle edition

In the fuction "hide", a semicolon is missing in the following line: e.style.display = "non" // hide element and use its space

Note from the Author or Editor:
Line should read: e.style.display = "non"; // hide element and use its space

Yoshiki Shibata  Feb 04, 2013  Aug 29, 2014