Errata

Speaking JavaScript

Errata for Speaking 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 45
Center of page

CHANGE FROM

Because Sun (now Oracle) had a trademark on the word _Java_, the official name of the language to be standardized couldn’t be _JavaScript_.

TO

Because Sun (now Oracle) had a trademark on the term _JavaScript_, it couldn’t be the official name of the language to be standardized.

Axel Rauschmayer
Axel Rauschmayer
 
Jan 25, 2015  Jan 30, 2015
PDF
Page 44
Last two sentences on page

CHANGE

In early December 1995, Java’s momentum had grown, and Sun licensed the trademark Java to Netscape. The language was renamed again, to its final name, JavaScript.

TO

In early December 1995, Java’s momentum had grown and the language was renamed again, to its final name, JavaScript.

Axel Rauschmayer
Axel Rauschmayer
 
Jan 25, 2015  Jan 30, 2015
PDF
Page 3
Center of page

"there is a trademark on _Java_" -> "there is a trademark on _JavaScript_"

Axel Rauschmayer
Axel Rauschmayer
 
Jan 25, 2015  Jan 30, 2015
PDF
Page 177
Center of page

The last code line on the page reads as follows:

selectEntries(posArg1, posArg2, { namedArg1: 7, namedArg2: true });

In that line, replace the first word "selectEntries" with "someFunc".

Axel Rauschmayer
Axel Rauschmayer
 
Jan 23, 2015  Jan 30, 2015
PDF
Page 203
Bottom fourth

The first word in "Tthe following function checks whether value is an object:" is a typo => replace "Tthe" with "The".

Axel Rauschmayer
Axel Rauschmayer
 
Jan 23, 2015  Jan 30, 2015
PDF
Page 276
Bottom fourth

In the sentence "Indices are numbers _i_ in the range 0 ≤ `i` < 2^32^−1.", the index "i" is first formatted as italics, second as code. Format both as italics (_i_).

Axel Rauschmayer
Axel Rauschmayer
 
Jan 23, 2015  Jan 30, 2015
PDF
Page 118
Last line before Sect. "Integers via the Custom Function ToInteger()"

Expression after "Therefore, Math.round(x) is the same as:":

REPLACE

Math.ceil(x + 0.5)

WITH

Math.floor(x + 0.5)

Axel Rauschmayer
Axel Rauschmayer
 
Jan 23, 2015  Jan 30, 2015
PDF
Page 330
Starting in the middle of the page

In the section "Other Functions", all items have the prefix "Math.", except for "min" and "max". Add the prefix there, too.

Axel Rauschmayer
Axel Rauschmayer
 
Jan 23, 2015  Jan 30, 2015
PDF
Page Last page of PDF
First paragraph of "About the Author"

I’m not editor of JavaScript Weekly, anymore, delete the following part of the sentence: ", edits JavaScript Weekly"

Axel Rauschmayer
Axel Rauschmayer
 
Jan 23, 2015  Jan 30, 2015
PDF
Page 417
Start of bottom third

I’m not editor of JavaScript Weekly, anymore => remove the complete note including parentheses: '(disclaimer: I’m editor of the “JavaScript Weekly” newsletter)'

Axel Rauschmayer
Axel Rauschmayer
 
Jan 23, 2015  Jan 30, 2015
PDF
Page 218
Center of page

Second code snippet on page.

REPLACE

Array.prototype.push.apply(result, Object.getOwnPropertyNames(obj));

WITH

result = result.concat(Object.getOwnPropertyNames(obj));

Axel Rauschmayer
Axel Rauschmayer
 
Jan 12, 2015  Jan 30, 2015
PDF
Page 210
Top of page

"Obviously, this" -> "This" (that is, remove "Obviously")

Axel Rauschmayer
Axel Rauschmayer
 
Jan 12, 2015  Jan 30, 2015
PDF
Page 188
Second item in bullet list

"an object with that scopes variables" -> "an object with that scope’s variables"

Axel Rauschmayer
Axel Rauschmayer
 
Jan 12, 2015  Jan 30, 2015
PDF
Page 174
Center of page

Replace "the variable in an array" with "the variable, e.g. in an array"

Axel Rauschmayer
Axel Rauschmayer
 
Jan 12, 2015  Jan 30, 2015
PDF
Page 163
Top of page

– In both code snippets: replace "catchit" with "catchIt" (three times) and "throwit" with "throwIt" (three times). That is, the "i" should be a capital letter in all cases.

– Replace "catch(e)" with "catch (e)". That is: insert a space before the opening parenthesis.

Axel Rauschmayer
Axel Rauschmayer
 
Jan 12, 2015  Jan 30, 2015
PDF
Page 162
Top of page

REPLACE

for example, while parsing code via `eval()`:

WITH

either while parsing normal code or while parsing the argument of `eval()`. For example:

AND REPLACE the two lines of the code snippet with the following four lines:

> 3..1
SyntaxError: Unexpected number '.1'. Parse error.
> eval('5 +')
SyntaxError: Unexpected end of script

Axel Rauschmayer
Axel Rauschmayer
 
Jan 12, 2015  Jan 30, 2015
PDF
Page 154
Starting in the middle

Three times: replace “logit” with “logMessage”.

Axel Rauschmayer
Axel Rauschmayer
 
Jan 12, 2015  Jan 30, 2015
PDF
Page 123
Top third

In the two items `-number` and `+number`, the word "argument" should be replaced with "operand". That’s a total of 2 replacements.

Axel Rauschmayer
Axel Rauschmayer
 
Jan 12, 2015  Jan 30, 2015
PDF
Page 64
Top of page

In the first two code snippets, the line following 'use strict' is:

{

But it should be (same indentation = same preceding four spaces):

if (true) {

Axel Rauschmayer
Axel Rauschmayer
 
Jan 12, 2015  Jan 30, 2015
PDF
Page 60
Center of page

In both code snippets, the name of the method is "foreach", but it should be "forEach". That is: make 2 replacements.

Axel Rauschmayer
Axel Rauschmayer
 
Jan 12, 2015  Jan 30, 2015
Printed, PDF
Page 25
bottom half of the page

This statement is not true.

"Hence, the previous two checks could also be performed like this"

Checking for undefined is different from using the in statement, as it is possible to have properties on an object that are set to undefined.

For example:

var obj = {};
obj.a = undefined;

a in obj // true
obj.a === undefined // true

Note from the Author or Editor:
Right. I didn’t want to make things to complicated here. Best solution is probably the following footnote, referred to at the end of "Hence, the previous two checks could also be performed like this":

Note: this check will report properties as non-existent that do exist, but have the value `undefined`.

Chris Aaker  Oct 08, 2014  Jan 30, 2015
Printed, PDF
Page 13
Under the heading Truthy and Fasly

"Number: -0, NaN"

should read

"Number: 0, NaN"

or

"Number: 0, -0, NaN"

as 0 makes more since than -0, conceptually.


Note from the Author or Editor:
The first way to fix this is best (as I’m usually pretending that there’s only a single zero).

Chris Aaker  Sep 17, 2014  Jan 30, 2015
Printed, PDF
Page 7
Under the Values heading

"All values in JavaScript have properties" should read "Most values in JavaScript have properties".

null and undefined are two values which do not have properties. Each is the single value of its own type. That is type Null has one value null that does not have properties. Also, type Undefined has one value undefined which does not have properties.

Note from the Author or Editor:
I don’t want to make things too complicated, but a footnote is in order. Thus: At the end of the sentence "All values in JavaScript have properties", add the following footnote: "The two “non-values” `undefined` and `null` do not have properties."

Chris Aaker  Sep 17, 2014  Jan 30, 2015
Printed, PDF
Page 214
26th line

var jane = Object.create(PersonProto);
jane.value = 'Jane';

->

var jane = Object.create(PersonProto);
jane.name = 'Jane';

Note from the Author or Editor:
Yes. Correction exactly as mentioned in the description of the error (first of the two lines stays the same):

var jane = Object.create(PersonProto);
jane.value = 'Jane';

->

var jane = Object.create(PersonProto);
jane.name = 'Jane';

Sangbok Lee  Jul 22, 2014  Jan 30, 2015
ePub
Page 282
last paragraph

iBooks version, 'page' 282 of 966, end of Ch 12.

Demonstrating replacement via regex, the following example has an incorrect second line:

> function repo(all) { return '('+all.toUpperCase()+')' }
> 'axbbyyxaa'.repl(/a+|b+/g, replacement)
'(A)x(BB)yyx(AA)'

I think you meant something like the second line, below:

> function repl(all) { return '(' + all.toUpperCase() + ')' }
> 'axbbyyxaa'.replace(/a+|b+/g, repl)
'(A)x(BB)yyx(AA)'

Note from the Author or Editor:
Correct! Change the second line in the code snippet. FROM

> 'axbbyyxaa'.repl(/a+|b+/g, replacement)

TO

> 'axbbyyxaa'.replace(/a+|b+/g, repl)

Steven Smolinski  May 23, 2014  Jan 30, 2015
Printed
Page 288
Bottom of page.

In addition to the repeated return, the book is missing a colon in the conditional:

return a < b ? -1 (a > b ? 1 : 0);

should be:

return a < b ? -1 : (a > b ? 1 : 0);

Note from the Author or Editor:
Yes, two typos. Replace the line
return return a < b ? -1 (a > b ? 1 : 0);
with
return a < b ? -1 : (a > b ? 1 : 0);

Jim Fathman  May 21, 2014  Jan 30, 2015
Printed
Page 379
Bottom of page

"latter" should be replaced by "former" in "However, the latter is normally the better choice"

Note from the Author or Editor:
True. Let’s fix this differently, so that things are in sync with the code example. Replace the first two sentences:

"Several literals produce objects that can also be created by constructors. However, the latter is normally the better choice:"

with "Several constructors produce objects that can also be created by literals. The latter is normally the better choice:"

Jeff Straw  May 06, 2014  Jan 30, 2015
Printed
Page 207
Paragraph above heading "A library method"

This sentence seems confusing: "The preceding array still has one element too many, null" - it implies that an unneeded element must be deleted. Do you mean instead that the approach requires an extra element (null) to be inserted, as you demonstrate with concat()?

Note from the Author or Editor:
Good point. Replace the following sentence:

The preceding array still has one element too many, `null`. We can use `concat()` to prepend it:

->

The preceding array contains `null`, followed by the elements of `arr`. We can use `concat()` to create it by prepending `null` to `arr`:

Jeff Straw  Apr 29, 2014  Jan 30, 2015
Printed
Page 195
Diagram in center of page

In step 5, after the execution of inc(1), the next call of inc() will start from 6 rather than from 5. Should the value of 5 in the bottom block beside startValue be changed to 6 to represent this? If not, does the modified environment appear at all in the diagram?

Note from the Author or Editor:
True. Change the following two diagrams on page 195:

4. Is: [ step | 5 ] Should be: [ step | 1 ]
5. Is: [ startValue | 5 ] Should be: [ startValue | 6 ]

Jeff Straw  Apr 28, 2014  Jan 30, 2015
Printed, Other Digital Version
Page 168, 169
Bottom of 168, top of 169

In the pair of examples showing that a var declaration is hoisted but its assignment is not, a named function expression rather than a normal function expression appears. In addition, the name "foo" appears twice, both as the name of the var and the name of the function. The example should perhaps be this instead:
var foo = function () { ... }; // (split over multiple lines as desired)

Note from the Author or Editor:
Yes, I agree that that would be better. Thus: in the last two code snippets before Sect. "The Name of a Function", replace

foo = function foo() {

WITH

foo = function () {

Jeff Straw  Apr 27, 2014  Jan 30, 2015
Printed, Other Digital Version
Page 152
near center of page

Case labels in the switch statement are complete color names except for one. "or" should be replaced with "orange" for consistency.

Note from the Author or Editor:
Yes, a typo. Replace the following line:

case 'or':

with:

case 'orange':

Jeff Straw  Apr 26, 2014  Jan 30, 2015
Printed
Page 191
2nd paragraph

The phrase "faculty function" should probably be "factorial function".

Note from the Author or Editor:
Indeed. Same word in German, but not in English. ;-)

Thus: "faculty function" -> "factorial function"

Jim Fathman  Apr 26, 2014  Jan 30, 2015
Printed
Page 160
First paragraph.

This sentence:

If one of the try_statements is a return, then the try block is executed afterward

may have intended:

If one of the try_statements is a return, then the try block is exited afterward

or alternatively:

If one of the try_statements is a return, then the finally block is executed afterward

Note from the Author or Editor:
True. Change: "then the `try` block is executed afterward" -> "then the `finally` block is executed afterward"

Jim Fathman  Apr 20, 2014  Jan 30, 2015
Printed, Other Digital Version
Page 22
First paragraph under Variable Scoping and Closures heading

> y; // This results in listed error (ReferenceError: y is not defined)
> y = 4; // This defines and initializes global variable y - no error thrown

Note from the Author or Editor:
True. I was thinking about strict mode. Fix: Replace all of the existing 4 lines with the following 5 lines.

[role="repl"]
------------------------------------
> var x;
> x
undefined
> y
ReferenceError: y is not defined
------------------------------------

Jeff Straw  Apr 20, 2014  Jan 30, 2015
PDF
Page 71
Compared by reference section

Example is shown:

> {} === {} // two different empty objects
false

but this returns a syntax error.

Note from the Author or Editor:
Same issue as on page 10: Not a syntax error in all command lines (e.g. not in Node.js). But a good idea to add parentheses, as shown in the following line:

> ({} === {}) // two different empty objects

Anonymous  Apr 10, 2014  Jan 30, 2015
PDF
Page 10
Compared by reference section

Example is shown:

> {} === {} // two different empty objects
false

but this returns a syntax error.

Note from the Author or Editor:
Not a syntax error in all command lines (e.g. not in Node.js). But a good idea to add parentheses, as shown in the following line:

> ({} === {}) // two different empty objects

Anonymous  Apr 10, 2014  Jan 30, 2015
PDF
Page 291
second paragraph

'Strict equality (seev' should be 'Strict equality (see'

Note from the Author or Editor:
Correct: "Strict equality (seev" -> "Strict equality (see "
That is: space instead of "v".

Lyall Braidwood  Mar 09, 2014  Jan 30, 2015
PDF
Page 176
section 'named parameters as descriptions'

selectEntries(3, 20, 2); what do these two numbers mean?
'two numbers' should probably read 'three numbers'

Note from the Author or Editor:
Yes: "what do these two numbers mean?" -> "what do these three numbers mean?"

Lyall Braidwood  Mar 09, 2014  Jan 30, 2015