Secrets of the JavaScript Ninja — errata
-
In chapter 1, page 10, section 1.4.2:
A comment in the code snippet is terminated with*//
. It should be terminated with*/
. - Page 39, first paragraph following the code example:
Thecompare()
method of the inline Comparator implementation is expected to return a positive number if the order of the passed values should be reversed, a negative number if not, and zero if the values are equal, so simply subtracting the values produces the desired return value to sort the array into descending order. -
In chapter 4, page 74, listing 4.9:
The line identified with (1) annotation should read:
if (!isPrime.answers) isPrime.answers = {};
. -
In chapter 7, page 157, table 7.1:
The Unicode hexadecimal terms, \x0000 and \xFFFF are incorrect. They should be \u0000 and \uFFFF. -
In chapter 7, page 161, listing 7.4:
The regular expression passed to match() should be/opacity=([^)]+)/
It is correct in the example code. -
In chapter 8, page 206, listing 9.7:
The expressionbase2.namespace ==
has an extra equals sign. It should bebase2.namespace =
. -
In chapter 11, page 246, listing 11.3:
The following excerpt doesn't match the source code:if (!window.findByTagWorksAsExpected) { for (var n = allElements.length - 1; n >= 0; n--) { if (allElements[n].nodeType === 1) allElements.splice(n,1); } }
if (!window.findByTagWorksAsExpected) { var onlyElements = []; for (var n = 0; n < allElements.length; n++) { if (allElements[n].nodeType === 1) onlyElements.push(allElements[n]); } allElements = onlyElements; }
-
In chapter 12, page 268, listing 12.7:
In the line annotated by callout 5, the property should beborderWidth
.
This change should be made in the example code filechapter-12/listing-12.7.html
.