Errata

High Performance JavaScript

Errata for High Performance JavaScript

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 6
Fourth paragraph

Please insert the following paragraph as a note before the section title "Dynamic Script Elements":

A change in HTML5's definition of the defer attribute was implemented in Internet Explorer 8 (standards mode) and Firefox 3.6. In both cases, <script> elements with a defer attribute specified now ignore inline script code and instead require the use of the src attribute. As such, the previous example will not function correctly in these browsers. Internet Explorer 8 running in compatibility mode still exhibits the older behavior.

Nicholas C. Zakas
Nicholas C. Zakas
 
Jun 05, 2010  Aug 07, 2015
Printed
Page 17
Figure 2-2

Shouldn't figure 2-2's "Add" node be "add"?

Note from the Author or Editor:
In Figure 2-2, please change "Add" (uppercase) to "add" (lowercase)

Anonymous  Aug 02, 2010  Aug 07, 2015
Printed
Page 18
Figure 2-3

In Figure 2-3, "var Total = add(5, 10);" should read "var total = add(5, 10);".

Note from the Author or Editor:
In Figure 2-3, please change

"var Total = add(5, 10);"

to

"var total = add(5, 10);"

(lowercase "t")

John Peloquin  Nov 28, 2010  Aug 07, 2015
Printed
Page 18
2nd paragraph

In the sentence

"This process continues until either the identifier is found or there are no more variable objects to search, in which case the identifier is deemed to be undefined."

the word "undefined" should probably read "undeclared", to avoid confusion.

Note from the Author or Editor:
In the sentence, "This process continues until either the identifier is found or there are no more variable objects to search, in which case the identifier is deemed to be undefined."

Please change "undefined" to "undeclared".

John Peloquin  Nov 28, 2010  Jun 03, 2011
PDF
Page 19-20
Figure 2-4, Figure 2-5

The legends for both figures indicate that Internet Explorer 8 is the dashed red line. That seems unlikely; it's more likely that Internet Explorer 8 is the solid red line (and, perhaps, that Firefox 3.5 is the dashed line). That would match the text which states:

"Browsers with optimizing JavaScript engines, such as Chrome and Safari 4, don't have this sort of performance penalty for accessing out-of-scope identifiers, whereas Internet Explorer, Safari 3.2, and others show a more drastic effect."

Note from the Author or Editor:
On the graph on page 19, please make the following changes:

1. Remove the legend.
2. Add a label to the right of the farthest-right dot for each line. The labels should be (going from top to bottom):
a. IE7
b. IE8
c. Safari 3.2
d. Firefox 3
e. Firefox 3.5
f. Opera 9.64
g. Opera 10
h. Chrome

Note that the lowest two lines are both different version of Chrome. Since they track the x-axis, it's fine to combine those lines into one and label it simply as "Chrome"

On the graph on page 20, please make the following changes:

1. Remove the legend.
2. Add a label to the right of the farthest-right dot for each line. The labels should be (going from top to bottom):
a. IE7
b. IE8
c. Safari 3.2
d. Firefox 3
e. Opera 9.64
f. Opera 10
g. Firefox 3.5
h. Chrome

Note: Opera 9.64 and Opera 10 lines are almost on top of one another. If one of the lines can be removed, then just label it as Opera 10. Also, as with the graph on page 19, the Chrome 1 and Chrome 2 lines track the x-axis, so one of them can be removed and the remaining line simply labeled as "Chrome".

Michael Lenaghan  Nov 29, 2010  Aug 07, 2015
Printed
Page 21
2nd paragraph

In the sentence:

Instead of accessing a global variables three times, that number is cut down to one.

"variables" should be "variable".

Note from the Author or Editor:
In the sentence, "Instead of accessing a global variables three times, that number is cut down to one." the word "variables" should be changed to "variable".

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 23
Figure 2-6

In Figure 2-6, in the activation object "(window)" should read "window" and in the global object the variable total should not exist.

Note from the Author or Editor:
In Figure 2-6, in the box labeled "Activation Object", change

(window)

To

window

John Peloquin  Nov 28, 2010  Aug 07, 2015
Printed
Page 25
2nd paragraph

In the sentence:

This event handler is a closure, as it is created when the assignEvents() is executed and can access the id variable from the containing scope.

It should be:

... when assignEvents() is executed ...

or

... when the assignEvents() function is executed ...

Note from the Author or Editor:
In the sentence beginning, "This event handler is a closure, as it is created when the assignEvents() is executed" remove the word "the".

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 26
Figure 2-8

In Figure 2-8, the arguments collection in the closure's activation object should contain the event object.

Note from the Author or Editor:
In Figure 2-8, in the Activation Object (Closure) box, please replace the [] in the second row, second column with [event].

John Peloquin  Nov 28, 2010  Aug 07, 2015
Printed
Page 27
5th paragraph

The sentence

"Any time you create an instance of a built-in type, such as Object or Array, these instances automatically have an instance of Object as their prototype."

is incorrect since Object.prototype is not an instance of Object (so an object literal, for example, is an instance of Object, but has Object.prototype as its prototype and hence does not have an instance of Object as its prototype).

Note from the Author or Editor:
Please change this sentence:

"Any time you create an instance of a built-in type, such as Object or Array, these instances automatically have an instance of Object as their prototype."

To this:

"Any time you create an instance of a built-in type other than Object, such as Date or Array, these instances automatically have an instance of Object as their prototype."

Also, note that "Object", "Date" and "Array" should all be in code font.

John Peloquin  Nov 28, 2010  Jun 03, 2011
Printed
Page 28
4th paragraph

"because title is an object instance" should read "because title is an instance property".

Note from the Author or Editor:
Please change "because title is an object instance" to "because title is an instance property" in the 4th paragraph.

John Peloquin  Nov 28, 2010  Jun 03, 2011
Printed
Page 31
last paragraph

In the sentence:

To be more accurate, you should be careful to use object member only when necessary.

"member" should be "members"

Note from the Author or Editor:
In the sentence, "To be more accurate, you should be careful to use object member only when necessary.", the word "member" should be "members".

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 31
Graph

The graph is extremely hard to read.

Note from the Author or Editor:
For the graph on page 31, please make the following changes:

1. Remove the legend
2. Remove the line for Opera 9.64
3. Remove the line for Chrome 1
2. Insert to the right of the farthest right dot on each line the following labels (one per line):
a. IE7
b. IE8
c. Safari 3.2
d. Opera 10
e. Firefox 3
f. Firefox 3.5
g. Chrome
h. Safari 4

Note that the lines for Chrome and Safari 4 are very close together, but Chrome should be on top of Safari 4.

Nicholas C. Zakas
Nicholas C. Zakas
 
May 30, 2011  Aug 07, 2015
Printed
Page 38
example code near the bottom

In this line of code:

h.push(' <li><a href="delete.php?id="' + i + '-id001">delete<\/a><\/li>');

the extra " after id= and the -id001 should be removed:

h.push(' <li><a href="delete.php?id=' + i + '">delete<\/a><\/li>');

Note from the Author or Editor:
The line:

h.push(' <li><a href="delete.php?id="' + i + '-id001">delete<\/a><\/li>');

Should be:

h.push(' <li><a href="delete.php?id=' + i + '">delete<\/a><\/li>');

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 40
Side note

The side note indicates that the example code used string concatenation and not an array, but the example did use an array.

Note from the Author or Editor:
Please remove the entire paragraph beginning "As a side note".

John Peloquin  Nov 28, 2010  Jun 03, 2011
PDF
Page 42
Fourth paragraph from bottom

Erroneously stated that document.links is a collection of "All a elements". It is, in fact, all a elements with an href value.

Note from the Author or Editor:
The description of document.links currently reads:

"All a elements"

It should read

"All a and area elements with href attributes"

Please note that "a", "area", and "href" should be in code print (monospaced).

James Bradley  Sep 27, 2010  Jun 03, 2011
Printed
Page 44
towards the bottom of the page

There is a sentence that reads, "But looping over an array is faster that looping over a collection...". I think "than" was meant instead of "that".

Note from the Author or Editor:
In the sentence, beginning "But looping over an array is faster that looping over a collection", replace "that" with "than".

Michael Matuzak  Apr 12, 2010  Jun 03, 2011
Printed
Page 48
3rd line final word

"because there are usually less items to loop over" should be "because there are usually fewer items to loop over"

Note from the Author or Editor:
Please change

"because there are usually less items to loop over"

to

"because there are usually fewer items to loop over"

Nick Tulett  Oct 06, 2010  Jun 03, 2011
Printed
Page 49
Caption for figure 3.6

"The benefit of using the Selectors API over iterating instead of the results of getElementsByTagName()"

should be

"The benefit of using the Selectors API over iterating the results of getElementsByTagName()"

i.e. remove "instead of"

Note from the Author or Editor:
Please change the caption for Figure 3-6 to read:

The benefit of using the Selectors API instead of iterating over the results of getElementsByTagName()

Nick Tulett  Oct 06, 2010  Jun 03, 2011
Printed
Page 54
Numbered list option 1

1. Take the element off of the document flow
should be
1. Take the element out of the document flow

Note from the Author or Editor:
Please change

1. Take the element off of the document flow

to

1. Take the element out of the document flow

Nick Tulett  Oct 06, 2010  Jun 03, 2011
Printed
Page 59
Example code, fourth line from top of page.

as published:
"ajaxrequest('xhr.php?page=' + id, updatePageContents);"
corrected:
"ajaxrequest('xhr.php?page=' + pageid, updatePageContents);"

Note from the Author or Editor:
Please replace the line:

ajaxrequest('xhr.php?page=' + id, updatePageContents);

With this (replace "id" with "pageid"):

ajaxrequest('xhr.php?page=' + pageid, updatePageContents);

Jeff Roberson  Sep 17, 2010  Jun 03, 2011
Printed
Page 59
Summary

Use of drag and drop proxies is mentioned in the summary, but not earlier in the chapter.

Note from the Author or Editor:
The bullet that says:

Position absolutely during animations, and use drag and drop proxies.

Should be changed to:

Position absolutely during animations.

John Peloquin  Nov 28, 2010  Jun 03, 2011
Printed
Page 62
note after first paragraph

In this sentence:

JavaScript has only function-level scope, and so defining a new variable inside of a for loop is the same as defining a new function outside of the loop.

Maybe I just misunderstood this, but it seems to me that "defining a new function" should be "defining a new variable".

Note from the Author or Editor:
In the first note, the phrase "defining a new function outside of the loop" should be "defining a new variable outside of the loop."

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 63
example code

i is never incremented in the while loop.

This line:

process(object[props[i]]);

should be:

process(object[props[i++]]);

Note from the Author or Editor:
In the code block, change the line:

process(object[props[i]]);

To:

process(object[props[i++]]);

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 64
top

In the code sample,

process(items[j++]]);

should read

process(items[j++]);

Also, the do-while loop fails if there are zero items, so technically it must be wrapped in an if-then to be equivalent to the other loops.

Note from the Author or Editor:
Please change

process(items[j++]]);

to

process(items[j++]);

John Peloquin  Dec 15, 2010  Jun 03, 2011
Printed
Page 65
top

In the code sample,

process(items[j++]]);

should read

process(items[j++]);

Also, the do-while loop fails if there are zero items, so technically it must be wrapped in an if-then to be equivalent to the other loops.

Note from the Author or Editor:
Please change

process(items[j++]]);

to:

process(items[j++]);

John Peloquin  Dec 15, 2010  Jun 03, 2011
Printed
Page 65
middle

In the code sample,

process(items[j]]);

should read

process(items[j]);

Also, the do-while loop fails if there are zero items, so technically it must be wrapped in an if-then to be equivalent to the other loops.

Note from the Author or Editor:
Please change

process(items[j++]]);

to:

process(items[j++]);

John Peloquin  Dec 15, 2010  Jun 03, 2011
Printed
Page 66
Example code

The last line of the example code is:

} while(--iterations);

It should be changed to:

} while(iterations--);

Nicholas C. Zakas
Nicholas C. Zakas
 
May 15, 2010  Jun 03, 2011
Printed
Page 67
last paragraph

In the sentence that begins with, "The fourth edition of ECMA-262 introduced...", was this meant to be "The fifth edition..."?

Note from the Author or Editor:
In the sentence beginning, "The fourth edition of ECMA-262," the word "fourth" should be changed to "fifth".

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 67
last paragraph

In the sentence:

The fourth edition of ECMA-262 introduced a new method on the native array object call forEach().

"call" should be "called"

Note from the Author or Editor:
In the sentence, "The fourth edition of ECMA-262 introduced a new method on the native array object call forEach()", the word "call" should be changed to "called".

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 67
sample code

The sample code does not work as expected, and in fact never escapes the while loop for most values of items.length. E.g. for items.length = 12, it processes:

first while loop:
i = 4
i = 3
i = 2
i = 1
second while loop:
i = 1
i = 0
i = -1
i = -2
i = -3
ad infinitum

I think the following code accomplishes the intended algorithm (e.g. for length 12 it processes from i=11 down to i=0):

var len = items.length;
var iterations = Math.floor(len / 8);
var i = len - 1;

while (iterations--) {
process(items[i]--);
process(items[i]--);
process(items[i]--);
process(items[i]--);
process(items[i]--);
process(items[i]--);
process(items[i]--);
process(items[i]--);
};

if (i >= 0) {
do {
process(items[i]);
} while (i--);
}

Note from the Author or Editor:
The first code example on page 67 should be:

//credit: Jeff Greenburg
var iterations = items.length % 8,
i = items.length - 1;

while(iterations){
process(items[i--]);
iterations--;
}

iterations = Math.floor(items.length / 8);

while(iterations){
process(items[i--]);
process(items[i--]);
process(items[i--]);
process(items[i--]);
process(items[i--]);
process(items[i--]);
process(items[i--]);
process(items[i--]);
iterations--;
}

larryl  May 06, 2010  Jun 03, 2011
Printed
Page 77
middle top of the page where the code example starts

In the iterative version of mergeSort() there is a comment that reads, "//uses the same mergeSort() function from previous example". I think "mergeSort()" should be "merge()".

Note from the Author or Editor:
The comment in the code example saying:

//uses the same mergeSort() function from previous example

Should be:

//uses the same merge() function from previous example

Michael Matuzak  Apr 12, 2010  Jun 03, 2011
Printed
Page 77
function mergeSort

Regarding the outer loop:

for (var lim=len; lim > 1; lim = (lim+1)/2)

Shouldn't the decrement operation be lim = Math.floor((lim+1)/2)? lim becomes a floating point when (lim+1) is an odd number. The loop will keep on going even when the numbers are already sorted because it will take several more operations before the floating point number becomes < 1.

Note from the Author or Editor:
Please replace this line in the example:

for (var lim=len; lim > 1; lim = (lim+1)/2){

With this line:

for (var lim=len; lim > 1; lim = Math.floor((lim+1)/2)){

Art Kho  Oct 06, 2010  Jun 03, 2011
Printed
Page 77
Top paragraph

The book mentions that the recursive implementation of mergeSort will end up calling mergeSort 2*N-1 times, which is correct. It then claims that this will blow the stack in Firefox for a 1500-item array. The maximum call nesting depth, however, is log(N), not 2*N-1, so for 1500 elements you'll get a call depth of eleven, which is unlikely to blow any stack.

Note from the Author or Editor:
Please replace the last sentence in the first paragraph with:

Recursive functions are a very common cause of stack overflow errors in the browser.

Marijn Haverbeke  Oct 27, 2010  Jun 03, 2011
Printed
Page 78
2nd paragraph

In the sentence:

Since the factorial of 6 is equal to 6 multiplied by the factorial 5, the factorial of 5 is being calculated twice.

"multiplied by the factorial 5" should be "multiplied by the factorial of 5"

Note from the Author or Editor:
In the sentence, "Since the factorial of 6 is equal to 6 multiplied by the factorial 5, the factorial of 5 is being calculated twice." the phrase "multiplied by the factorial 5" should be "multiplied by the factorial of 5".

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 78
2nd example

For clarity, there should not be a space between memfactorial and (n-1).

Note from the Author or Editor:
In second code example, change this line:

memfactorial.cache[n] = n * memfactorial (n-1);

To:

memfactorial.cache[n] = n * memfactorial(n-1);

(Remove the space between memfactorial and (n-1).

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 79
paragraph before the summary

There is a sentence that reads, "Generic memoization of this type is less optimal that manually updating the algorithm..." I believe "that" should be "than".

Note from the Author or Editor:
In the sentence beginning, "Generic memoization of this type is less optimal that manually updating the algorithm" the word "that" should be "than".

Michael Matuzak  Apr 12, 2010  Jun 03, 2011
PDF
Page 81
2nd paragraph

Change "and teaching you how to write regular expressions that take advantage of this" to "and showing you how to write regular expressions that take advantage of this".

Nicholas C. Zakas
Nicholas C. Zakas
 
May 09, 2010  Jun 03, 2011
PDF
Page 90
Figure 5-4

Figure 5-4, the bottom box has the word "hello" underlined with a small x for failure appearing to the right. The underline, the "x", and the word "failure" should be removed (they do not apply in the bottom box, only the top box).

Nicholas C. Zakas
Nicholas C. Zakas
 
May 09, 2010  Aug 07, 2015
Printed
Page 91
United States

"It then triest o match \/ (an escaped backslash)" should have said "an escaped forward slash".

Note from the Author or Editor:
On first full sentence on the page, please change "an escaped backslash" to "an escaped forward slash".

Darcy Parker  Sep 28, 2010  Jun 03, 2011
PDF
Page 95
Section "From bad to worse", Paragraph 2

The superscript for "n" in "O(2n)" was incorrectly removed, changing the meaning from "two to the nth power" to "two times n". Please change so that the "n" is a superscript.

Nicholas C. Zakas
Nicholas C. Zakas
 
May 09, 2010  Jun 03, 2011
PDF
Page 100
Third paragraph

The sentence

"In other browsers, the difference is less significant or is optimized differently altogether".

Should be changed to:

"In other browsers, the difference is less significant or is optimized away altogether."

Nicholas C. Zakas
Nicholas C. Zakas
 
May 09, 2010  Jun 03, 2011
Printed
Page 109
1st paragraph below Browser Limits

In the sentence:

Browsers place limits on the amount of time that JavaScript take to execute.

"take" should be "takes"

Note from the Author or Editor:
In the sentence, "Browsers place limits on the amount of time that JavaScript take to execute." the word "take" should be changed to "takes".

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 126
line 11/12 and 2nd last line of first example

Comment wrapped across line, making last word of comment a variable reference. Both need extra // on wrapped line

Note from the Author or Editor:
Change this line in the example:

req.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); // Set a request
header.


to be this:

req.setRequestHeader('X-Requested-With', 'XMLHttpRequest');

And change this line:

var responseHeaders = req.getAllResponseHeaders(); // Get the response
headers.

To be this:

var responseHeaders = req.getAllResponseHeaders();

David Moore  Mar 07, 2012  Aug 07, 2015
Printed
Page 127
last example

The jsonCallback function expects a string argument and uses eval to produce an object. However, this function is already passed an object as shown in the example on the next page.

The jsonCallback function should probably be defined like this instead:

function jsonCallback(data) {
// Process the data here...
}

Note from the Author or Editor:
Please change this function on page 127:

function jsonCallback(jsonString){
var data = eval(...);
//Process the data here
}

With this:

function jsonCallback(data){
//process the data here
}

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 132
Both code samples

The way the value for the Content-Length header is calculated is incorrect in both code samples in the page. Consider the first code sample that includes:

req.setRequestHeader('Content-Length', params.length);

which would be equivalent to running:

req.setRequestHeader('Content-Length', 2);

whereas it should be:

req.setRequestHeader('Content-Length', 18);

so the following code snippet would be more appropriate:

var data = params.join('&');
req.setRequestHeader('Content-Length', data.length);
req.send(data);

Note from the Author or Editor:
In *both* examples on page 132, replace these lines:

req.setRequestHeader("Content-Length", params.length);
req.send(params.join("&"));

With these lines:

(blank line)
var data = params.join("&");
req.setRequestHeader("Content-Length", data.length);
req.send(data);

Michael Bolin
Michael Bolin
 
Sep 19, 2010  Jun 03, 2011
Printed
Page 135
Example function: parseXML() at bottom of page.

This Javascript example has three similar errors; two on this page (135), and one on the next (136).

1st:
as published:
"username = (usernameNodes.firstChild) ?
usernameNodes.firstChild : '';"
corrected:
"username = (usernameNode.firstChild) ?
usernameNode.firstChild : '';"

2nd:
as published:
"realname = (realnameNodes.firstChild) ?
realnameNodes.firstChild : '';"
corrected:
"realname = (realnameNode.firstChild) ?
realnameNode.firstChild : '';"

Note from the Author or Editor:
In the code example at the bottom of page 135, please replace these lines:

username = (usernameNodes.firstChild) ?
usernameNodes.firstChild : '';

With these lines:


username = (usernameNode.firstChild) ?
usernameNode.firstChild : '';

Also, please replace these lines:

realname = (realnameNodes.firstChild) ?
realnameNodes.firstChild.nodeValue : '';

With these lines:

realname = (realnameNode.firstChild) ?
realnameNode.firstChild.nodeValue : '';

Please be sure that the indentation remains the same as it is now, only the words should change.

Jeff Roberson  Sep 17, 2010  Jun 03, 2011
Printed
Page 136
XML example using attributes

Each of the id attribute values have "-id001" appended to them. This should be removed.

Note from the Author or Editor:
Please remove all instances of the text "-id001" in the second example code. Snippets:

<user id="1-id001"

<user id="2-id001"

<user id="3-id001"

<user id="4-id001"

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 137
1st paragraph after the table

The sentence reads, "As you can see, using favoring attributes over child tags...".

"using" should be removed.

Note from the Author or Editor:
In the sentence, ""As you can see, using favoring attributes over child tags...", the word "using" should be removed.

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 141
example code

Each of the id attribute values has "-id002" appended to it. This should be removed.

Note from the Author or Editor:
In the example code, please remove the four instances of the text "-id002", as they appear (snippets only):

<li class="user" id="1-id002">

<li class="user" id="2-id002">

<li class="user" id="3-id002">

<li class="user" id="4-id002">

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 142
3rd paragraph

The sentence reads, "Keep in mind the main different between this format and all others..."

"different" should be "difference"

Note from the Author or Editor:
In the sentence, "Keep in mind the main different between this format and all others...", the word "different" should be "difference".

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 143
2nd paragraph

The sentence reads, "When creating you own custom format..."

"you" should be "your"

Note from the Author or Editor:
In the sentence, "When creating you own custom format...", the word "you" should be changed to "your".

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 144
Table on p.144-145

The size of each request is specified in bytes, but it does not specify whether it is the uncompressed or gzipped size. Presumably, it is the uncompressed size, but if the response is gzipped (as recommended elsewhere in the book), then some of the differences between using XML and JSON may be less significant, in which case the table is misleading.

Note from the Author or Editor:
In the paragraph just before the second table on the page, please add the following sentence at the end of the paragraph:

Note that size and download time are for uncompressed (not gzipped) data.

Michael Bolin
Michael Bolin
 
Sep 19, 2010  Jun 03, 2011
Printed
Page 148
code sample

msxml_progid has an unnecessary trailing comma in its array declaration.

Note from the Author or Editor:
This line:

'MSXML2.XMLHTTP.3.0', // Doesn't support readyState 3

should be changed to (remove comma):

'MSXML2.XMLHTTP.3.0' // Doesn't support readyState 3

Please keep the indentation exactly the same.

Nick Tulett  Oct 11, 2010  Jun 03, 2011
Printed
Page 155
2nd function

In the removeHandler() function, (DOM2 Events), the function call should be target.removeEventListener() and not target.addEventListener().

Note from the Author or Editor:
In the example,

//overwrite the existing function
if (target.removeEventListener){ //DOM2 Events
removeHandler = function(target, eventType, handler){
target.addEventListener(eventType, handler, false);


Should be

//overwrite the existing function
if (target.removeEventListener){ //DOM2 Events
removeHandler = function(target, eventType, handler){
target.removeEventListener(eventType, handler, false);

Darcy Parker  May 07, 2013  Aug 07, 2015
Printed
Page 157
bitwise operator examples

The result variable names are mistyped. They should be result1, result2, result3 and result4.

Note from the Author or Editor:
In the second code example, this line:

alert(resul2.toString(2)); //"11011"

Should be changed to:

alert(result2.toString(2)); //"11011"

The line:

alert(resul3.toString(2)); //"11000"

Should be changed to:

alert(result3.toString(2)); //"11000"

The line:

var result = ~25; //-26

Should be changed to:

var result4 = ~25; //-26


And the line:

alert(resul2.toString(2)); //"-11010"

Should be changed to:

alert(result2.toString(2)); //"-11010"

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 157
bitwise operator examples

Existing errata for this page is also wrong - the last line in the examples should be:

alert(result4.toString(2)); //"-11010"

not
alert(resul2.toString(2)); //"-11010"
or
alert(result2.toString(2)); //"-11010"

Note from the Author or Editor:
Please change the last two lines of the second example code on the page from:

var result = ~ 25; //-26
alert(resul2.toString(2)); //"-11010"

To:

var result4 = ~ 25; //-26
alert(result4.toString(2)); //"-11010"

Please make sure the // line up with the previous lines of code in the example.

Nick Tulett  Sep 29, 2010  Jun 03, 2011
PDF
Page 157
Near the bottom

The actual result of this code:

var result3 = 25 ^ 3; //26
alert(result3.toString(2)); //"11000"

is 11010, not 11000.

Note from the Author or Editor:
Please change this line in the second example:

alert(result3.toString(2)); //"11000"

To this:

alert(result3.toString(2)); //"11010"

jvlb  Oct 19, 2010  Jun 03, 2011
PDF
Page 157
2nd paragraph from the bottom

On the first example (AND) of the bitwise operators, the alert is using the wrong variable.

Instead of:
alert(result.toString(2));

This should be correct:
alert(result1.toString(2));

Note from the Author or Editor:
Replace "result" with "result1" in the specified code.

Christos Monogios  Apr 23, 2016 
Printed
Page 164
4th paragraph

The sentence reads, "A property can be evaluated by placing its name between ${and }."

There should be a space between "${" and "and".

Note from the Author or Editor:
In the sentence, "A property can be evaluated by placing its name between ${and }.", add a space between "${" and "and".

Bill Bryant  Apr 19, 2010  Jun 03, 2011
Printed
Page 178
first code sample

The line:

for (i = 0; i < count; i++) {

is indented two spaces, but it should not have any indent.

Note from the Author or Editor:
The first instance of this line is currently indented in the example code:

for (i = 0; i < count; i++) {

There should be no indent ("for" should align at the first column)

Michael Bolin
Michael Bolin
 
Sep 19, 2010  Jun 03, 2011
Printed
Page 179
second code sample

In the following line, the second string literal contains an extra space:

alert('created ' + count + ' in ' +

presumably it should be:

' in '

Note from the Author or Editor:
On this line:

alert('created ' + count + ' in ' +

Please ensure there is only one space before and after the word "in".

Michael Bolin
Michael Bolin
 
Sep 19, 2010  Jun 03, 2011
Printed
Page 181
second code sample

Call to Y.Profiler.getFullReport() is missing a closing paren:

Third line is:

};

but should be:


});

Note from the Author or Editor:
In the second code example, change the third line from:

};

To

});

Michael Bolin
Michael Bolin
 
Sep 19, 2010  Jun 03, 2011
Printed
Page 183
caption for figure 10-1

Should be "Firebug" rather than "FireBug."

Note from the Author or Editor:
Please replace the word "FireBug" with "Firebug".

Michael Bolin
Michael Bolin
 
Sep 19, 2010  Jun 03, 2011
Printed
Page 187
code sample

Extra space before the equals sign on this line:

element.className = 'foobar';

Note from the Author or Editor:
In the code, please ensure there is only one space between "element.className" and the equals sign in:

element.className = 'foobar';

Michael Bolin
Michael Bolin
 
Sep 19, 2010  Jun 03, 2011
Printed
Page 190
Figure 10-8

Case in code sample does not match that of figure.

On page 190, the code is:

foo.displayName = 'I am foo';

but in the figure on 191, the name is:

'i am foo'

so the case of 'i' is inconsistent.

Presumably it is easier to update the code sample than the screenshot.

Note from the Author or Editor:
Please change this line in the last code sample:

foo.displayName = "I am foo";

To this:

foo.displayName = "i am foo";

Note that the word "displayName" should still be bold.

Michael Bolin
Michael Bolin
 
Sep 19, 2010  Jun 03, 2011
Printed
Page 192
second paragraph in Chrome Developer Tools

Inconsistent comma placement:

"Loading", "Scripting," or "Rendering".

For consistency, this should be one of the following:

"Loading", "Scripting", or "Rendering".
"Loading," "Scripting," or "Rendering."

Note from the Author or Editor:
Please change this:

"Loading", "Scripting," or "Rendering".

To this:

"Loading", "Scripting", or "Rendering".

Michael Bolin
Michael Bolin
 
Sep 19, 2010  Jun 03, 2011
Printed
Page 200
2nd paragraph

The sentence reads, "...requests that a event may be triggering..."

"a event" should be "an event"

Note from the Author or Editor:
In the sentence containing, "...requests that a event may be triggering...", replace "a" with "an".

Bill Bryant  Apr 19, 2010  Jun 03, 2011