Errata

Maintainable JavaScript

Errata for Maintainable 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
PDF
Page X
last line

"code in a maintainable away allows you, ..." should be replaced with "code in a maintainable way allows you, ..."

Note from the Author or Editor:
Please replace "away" with "way" in the phrase:

"code in a maintainable away allows you"

zeroK  Apr 23, 2012  Jan 26, 2018
Printed
Page 41
Function Declarations, page bottom

I'm assuming you didn't mean to label this as "Bad" too?

// Bad
function doSomething() {
alert("Hello World!");
}

doSomething();

Note from the Author or Editor:
Please remove the comment "//Bad" from the code example

Anonymous  Dec 13, 2012  Jan 26, 2018
PDF
Page 42
1st paragraph, 2nd sentence

"Document comments MAKE take many forms..." instead of "Document comments MAY take many forms..."

Note from the Author or Editor:
Please change:

"Document comments make take many forms..."

to:

"Document comments may take many forms..."

Oliver Schmidt  May 01, 2012  May 09, 2012
PDF
Page 47
1st ordere list

"2. There is an extra line after before each case statement after the first one." - It seems that whether "2. There is an extra line before each case statement after the first one." or "2. There is an extra line after each case statement." would make sense. Seems like these two got intermingled here.

Note from the Author or Editor:
Please change

"2. There is an extra line after before each case statement after the first one."

To

"2. There is an extra line before each case statement after the first one."

Oliver Schmidt  May 01, 2012  May 09, 2012
Printed
Page 47
Last code example (bottom of page)

The final line of example code on the page says:

console.log(count); // 15

It should say:

console.log(number); // 15

Nicholas C. Zakas
Nicholas C. Zakas
 
May 13, 2013  Jan 26, 2018
PDF
Page 61
Inside first code snippet

Inside `function addItem(url, text)`, I believe
`result = sprintf(template, url, text);` was intended to be
`result = sprintf(templateText, url, text);`.

...or line 3: `templateText = mylist.firstChild.nodeValue,` should have been `template = mylist.firstChild.nodeValue,`

Also it seems Line 6: `div.innerHTML = result;` should be omitted. div is undefined, and the result is being inserted properly in line 7: `mylist.insertAdjacentHTML("beforeend", result);`.

Note from the Author or Editor:
Now on page 62. Please remove this line:

div.innerHTML = result;

DarcyParker  Apr 25, 2012  Jan 26, 2018
PDF
Page 61
Inside fourth code snippet

Inside `function addItem(url, text)`, I believe
`result = sprintf(template, url, text);` was intended to be
`result = sprintf(templateText, url, text);`.

Also:
I believe `list.appendChild(div.firstChild);` was intended to be `mylist.appendChild(div.firstChild);`.

It's also unclear as to why this snippet is using appendChild() whereas the first snippet used insertAdjacentHTML()... I believe they have the same effect, and I would probably have used appendChild() myself. But I am uncertain if there is a difference that I don't recognize. Since there is no discussion of this in the text, I thought I'd point it out and ask.

Note from the Author or Editor:
Now on page 62 -

Please change:

result = sprintf(template, url, text);

To:

result = sprintf(templateText, url, text);

DarcyParker  Apr 25, 2012  Jan 26, 2018
Printed
Page 62
bottom

at the very bottom is the same type:

"templateText" vs "template"

Note from the Author or Editor:
In last code example, change:

result = sprintf(template, url, text);

to

result = sprintf(templateText, url, text);

citykid72  Oct 02, 2013  Jan 26, 2018
PDF
Page 63
2nd line

I believe `list.appendChild(div.firstChild);` was intended to be `mylist.appendChild(div.firstChild);`

Note from the Author or Editor:
In the code, please change:

list.appendChild(div.firstChild);

To:

mylist.appendChild(div.firstChild);

DarcyParker  Apr 25, 2012  Jan 26, 2018
Printed
Page 63
2nd paragraph from the bottom

In the book it is written: "All you need to do is pass in an object containing the properties name and url"

it should be "... containing the properties text and url"

Note from the Author or Editor:
Please make the changes specified by the reader.

Christos Monogios  Feb 15, 2015  Jan 26, 2018
PDF
Page 68
3rd paragraph

In the sentence "Further, if color ends up..." the function sayColor() is broken as if it were two words: say<line break>Color(). It shouldn't be broken or should have a hyphen (though I think that would be odd for a function name to be hyphenated).

Note from the Author or Editor:
Please ensure that sayColor() is kept together as one work, without any hyphenation in the third paragraph.

admoman  Jun 30, 2013 
PDF
Page 73
top of this page, the code area

the namespace methods is not "nondestructively", it will overwritten some property;

code:

if(!object[parts[i]])

when object[parts[i]] is false or 0 it will be overwritten

maybe this will be better:

if(object[parts[i]] === undefined)

Note from the Author or Editor:
Replace the line:

if (!object[parts[i]]) {

With

if (typeof object[parts[i]] === "undefined") {

jfw10973  Apr 08, 2015  Jan 26, 2018
PDF
Page 77
2nd paragraph

In the sentence: "Most developers are familiar with the event object that is passed in to an event handler when the event is fired.", there is a typo...

'in to' should be 'into'.

Note from the Author or Editor:
Please change "in to" to "into" in this sentence:

"Most developers are familiar with the event object that is passed in to an event handler when the event is fired."

DarcyParker  Apr 26, 2012  Jan 26, 2018
PDF
Page 77
First Snippet

The first snippet has a comment:
// addListener() from Chapter 7
(It's actually from Chapter 5.)

Note from the Author or Editor:
Please change the reference to chapter 7 in the first code snippet to chapter 5.

DarcyParker  Apr 26, 2012  Jan 26, 2018
PDF
Page 79
3rd paragraph

"The placeholders in Handlebars templates are named so that they corresponding to named values in JavaScript." should be "The placeholders in Handlebars templates are named so that they ARE corresponding to named values in JavaScript." or "The placeholders in Handlebars templates are named so that they correspond to named values in JavaScript."

Note from the Author or Editor:
Please replace the word "corresponding" with "correspond".

olsch01  May 18, 2012  May 09, 2012
PDF
Page 84
Top of the page

Original text:

� For strings, typeof returns �string.�
� For numbers, typeof returns �number.�
� For booleans, typeof returns �boolean.�
� For undefined, typeof returns �undefined.�

Actually the "typeof" operator will return type name without a point, so that it will be "string", "number", "boolean" and "undefined" respectively.

Note from the Author or Editor:
In each of the bullets mentioned by the reader, please move the period after the closing parentheses. For example, "string." should be "string".

Artem Oboturov  Jun 25, 2012  Jan 26, 2018
PDF
Page 85
Note in 3rd paragraph

Original:

Running typeof null returns �object,�

comma is misplaced and should be after the double quote.

Note from the Author or Editor:
Please change:

Running typeof null returns "object,"

to

Running typeof null returs "object",

Artem Oboturov  Jun 25, 2012  Jan 26, 2018
PDF
Page 88
4th paragraph

Original:

For arrays, the string is �[object Array],�

again formatting error with punctuation inside value - already the 3rd one

Note from the Author or Editor:
Please change

�[object Array],�

to

�[object Array]�,

Artem Oboturov  Jun 25, 2012  Jan 26, 2018
PDF
Page 99
United States

Bullet 1

Once you�ve fixed a hard-to-debug error, try to add one or two custom errors that can help you more easily the solve the problem, should it occur again.

more easily the solve the problem.. (extra the)

Note from the Author or Editor:
Please remove "the" between "easily" and "solve".

Bob Hanson  May 31, 2012  Jan 26, 2018
Printed
Page 108
2nd paragraph

In book is written "There are may approaches, called design patterns, to extending ..."

it should be "There are many approaches, called design...."

Note from the Author or Editor:
Please make the changes suggested by the reader.

Christos Monogios  Feb 15, 2015  Jan 26, 2018
Printed
Page 110
line 2 from the bottom

I think this line is missing "this.".
element.className += " " + className;
should be
this.element.className += " " + className;

Note from the Author or Editor:
Please change:

element.className += " " + className;

To:

this.element.className += " " + className;

Anonymous  Apr 02, 2013  Jan 26, 2018
PDF
Page 112
bottom of the page

Refer to MDN, I can't find Object.preventExtension but Object.preventExtensions. I'm not sure this is a typo.

Note from the Author or Editor:
Please replace "Object.preventExtension" with "Object.preventExtensions".

Ivan Yan  Jul 04, 2013  Jan 26, 2018
PDF
Page 113
last paragraph

"Internet Explorer�s introduction now meant that everyone user-agent string detection was now also identifying this new browser as Netscape." would be better as
"Internet Explorer�s introduction meant that everyone's user-agent string detection method identified Internet Explorer as Netscape."

Note from the Author or Editor:
Please change:

"Internet Explorer�s introduction now meant that everyone user-agent string detection was now also identifying this new browser as Netscape."

To:

"Internet Explorer�s introduction meant that everyone's user-agent string detection method identified Internet Explorer as Netscape."

DarcyParker  Apr 26, 2012  Jan 26, 2018
PDF
Page 134
1st snippet

The //target[@name=version] is implied, but not defined in the first snippet. It's implied when showing the example output after the sentence: ""When this Ant script is executed, the output is:"

The first snippet should probably be something like this:

<?xml version="1.0" encoding="UTF-8"?>
<project name="maintainablejs" default="version">
<property name="version" value="0.1.0" />
<target name="version">
<echo>Version is ${version}</echo>
</target>
</project>

Note from the Author or Editor:
(Now on page 136)

Please replace first code snippet with (indents should be four spaces each):

<?xml version="1.0" encoding="UTF-8"?>

<project name="maintainablejs" default="version">

<property name="version" value="0.1.0" />

<target name="version">

<echo>Version is ${version}</echo>

</target>

</project>

DarcyParker  Apr 27, 2012  Jan 26, 2018
Printed
Page 170
First code snippet

The first code snippet, the directory for tests is incorrect. This line:

yuitestselenium.tests = ${lib.dir}/tests.xml

Should be changed to:

yuitestselenium.tests = ${tests.dir}/tests.xml

Nicholas C. Zakas
Nicholas C. Zakas
 
Oct 08, 2012  Jan 26, 2018
PDF
Page 192
Section Function Declarations, 1st paragraph, 4th and 5th sentences

"There should be one space between the closing parentheses and the right brace. The right brace should be on the same line as the function keyword."

In each sentence I believe you meant 'left' brace.

Note from the Author or Editor:
Please change:

"There should be one space between the closing parentheses and the right brace. The right brace should be on the same line as the function keyword."

To:

"There should be one space between the closing parentheses and the left brace. The left brace should be on the same line as the function keyword."

DarcyParker  Apr 24, 2012  Jan 26, 2018
PDF
Page 203
First code block

In the code example at the top of page 203, there is an unmatched double quote. This is the code block for the switch statement in Appendix A. The default case in this code block reads:

throw new Error("This shouldn't happen.);

There needs to be a closing double quote after the period:

throw new Error("This shouldn't happen.");

Note from the Author or Editor:
Please replace:

throw new Error("This shouldn't happen.);

With:

throw new Error("This shouldn't happen.");

Anonymous  Mar 29, 2013  Jan 26, 2018
Mobi
Page 2731
"advantages and Disadvantages", 3rd bullet

"JavaScript can processed in any number of ways before deployment,"

There is a missing verb-part -- should read "JavaScript can be processed..."

Note from the Author or Editor:
Please change "JavaScript can processed..." to "JavaScript can be processed..."

steve.clason  Jul 23, 2013  Jan 26, 2018