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.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Other Digital Version http://speakingjs.com/es5/ch15.html#_mandatory_parameters_enforcing_a_minimum_arity

The third approach throws an exception for foo() and sets optional to undefined for foo(undefined).

Did you mean to say sets mandatory to undefined? Since there is only one argument passed in foo(undefined), I am a bit confused as to how optional would be set to undefined.

Delta Notch  Mar 05, 2015 
Other Digital Version http://speakingjs.com/es5/ch16.html#_background_static_versus_dynamic

console.log(foo('hello')); // arg: hello

I think perhaps you meant to just say foo('hello'), since a call to console.log is already made inside of bar.

Delta Notch  Mar 06, 2015 
Other Digital Version http://speakingjs.com/es5/ch16.html#iife

The original text says:

(function () {
...
}()) // no semicolon
(function () {
...
}());

The preceding code is interpreted as a function call—the first IIFE (including the parentheses) is the function to be called, and the second IIFE is the parameter.

Did you mean to instead write this:

(function () {

}(function () {

}()));

I am having a hard time seeing how the second IIFE ends up becoming an argument of the first. Was there perhaps a mistake, or is this a peculiar way of Javascript interpreting function calls? From the way I understand it, the fact that there is no argument on the 3rd line means that the second IIFE should not be passed as an argument to the first. But there is a good chance I am wrong here.

Delta Notch  Mar 06, 2015 
Other Digital Version http://speakingjs.com/es5/ch17.html#_callbacks_and_extracted_methods

The text says:

Executing counter.count via callIt triggers a warning (due to strict mode):

Did you mean to say "counter.inc" instead?

Delta Notch  Mar 07, 2015 
Other Digital Version http://speakingjs.com/es5/ch17.html#_callbacks_and_extracted_methods

The text says:

Executing counter.count via callIt triggers a warning (due to strict mode):

Did you mean to say "counter.inc" instead?

Delta Notch  Mar 07, 2015 
Other Digital Version http://speakingjs.com/es5/ch17.html#_the_effects_of_enumerability

enumberability

Perhaps you meant "enumerability"

Delta Notch  Mar 07, 2015 
Other Digital Version http://speakingjs.com/es5/ch17.html#definition_vs_assignment

[ hasOwnProperty',
'valueOf',
'constructor',
'toLocaleString',
'isPrototypeOf',
'propertyIsEnumerable',
'toString' ]

Is this missing an apostrophe?

[ 'hasOwnProperty',
'valueOf',
'constructor',
'toLocaleString',
'isPrototypeOf',
'propertyIsEnumerable',
'toString' ]

Delta Notch  Mar 07, 2015 
Other Digital Version http://speakingjs.com/es5/ch17.html#_privileged_methods

function Constr(...) {
...
this.privilegedMethod = function (...) {
// Access everything
privateData = ...;
privateFunction(...);

this.publicData = ...;
this.publicMethod(...);
};
}

If I understand correctly, the function expression assigned to this.privilegedMethod cannot use the keyword 'this' but should instead use 'that' since every function expression has a different value for this (in this case, this would probably be undefined). So, we should have that.publicData = ...; or that.publicMethod(...);. Or we could rewrite it as so:

this.privilegedMethod = function(...) {
...
}.bind(this);

Delta Notch  Mar 10, 2015 
Other Digital Version

toString() is preferred by the conversion to string:

> String({ toString: function () { return 'ME' } })
'Result: ME'

I think 'Result: ' should be omitted

Delta Notch  Mar 10, 2015 
Other Digital Version http://speakingjs.com/es5/ch18.html#_comparing_numbers

function compareCanonically(a, b) {
return return a < b ? -1 (a > b ? 1 : 0);
}

Did you perhaps mean to say:

function compareCanonically(a, b) {
return a < b ? -1 : (a > b ? 1 : 0);
}

Delta Notch  Mar 11, 2015 
Other Digital Version http://speakingjs.com/es5/ch18.html#_comparing_objects

The parameter compareFunction is also useful for sorting objects:

Did you mean to say compareNames?

Delta Notch  Mar 11, 2015 
Other Digital Version http://speakingjs.com/es5/copyright.html

I think you may have forgotten to close the <title> tag in the HTML (or closed it improperly?) so that the entire page is not rendering.

Delta Notch  Mar 12, 2015 
Other Digital Version http://speakingjs.com/es5/ch19.html#_matching_everything_or_nothing

The group matches everything, while not capturing anything, which the group from influencing the result returned by exec().

Did you mean to say: which "prevent" the group?

Delta Notch  Mar 12, 2015 
Other Digital Version http://speakingjs.com/es5/ch16.html#iife

Sorry, I retract what I wrote regarding this code:

(function () {
...
}()) // no semicolon
(function () {
...
}());

I see what you mean now. The first IIFE, after evaluating, is expected to be a function object, which receives another function expression as its argument. You were right -- I made a mistake in interpreting it.

Delta Notch  Mar 18, 2015 
Chapter 12. the last code about String.prototype.replace

In the Books,the last code :
> function repl(all) { return '('+all.toUpperCase()+')' }
> 'axbbyyxaa'.repl(/a+|b+/g, replacement)
'(A)x(BB)yyx(AA)'

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

bingxl  Aug 21, 2017 
Other Digital Version 7
Chapter 7: JavaScript's Syntax - Strict Mode section

The sub-header 'The arguments objects has fewer properties' contains a typo: 'objects' should be 'object.'

It's in Chapter 7, in the Strict Mode section.

Brent Guffens  Dec 29, 2016 
PDF Page 109
Under title: Best practice: pretend there’s only one zero.

It's stated that:

This is what you see when you use a browser command line or the Node.js REPL:
> -0
0

but trying this in:
1. Node.js REPL v0.12.0
2. FireFox Developer Edition Build 38.0a2 (2015-03-24)
3. Google Chrome Version 41.0.2272.104 (64-bit)

all on Mac OS X 10.10.2 yields the following results:

> -0
-0

Mohammed Medhat  Mar 25, 2015 
Printed Page 118
Expression after "Therefore, Math.round(x) is the same as:":

Expression after
"Therefore, Math.round(x) is the same as:":
Math.ceil(x+0.5)
is wrong..I think even published errata is also wrong...you can check the expression given in errata for Math.round(3.2) to validate it

Jobinesh   Oct 02, 2015 
Printed Page 119
4th paragraph

"...this formula is relatively complicated because floor seeks the closest larger integer; if you want to remove the fraction of a negative integer, you have to seek the closest smaller integer."

logically, the word "larger" should be replaced with "smaller" and vice-versa.

that is:
".... this formula is relatively complicated because floor seeks the closest smaller integer; if you want to remove the fraction of a negative integer, you have to seek the closest larger integer."

Wei Zhou  Aug 23, 2016 
Printed Page 123
middle page

For variable++ and variable-- operators it is said that they increments (or decrements) the value of the variable by 1 and returns it, but in the example shows correctly the opposite: return first and increment after that:
> var x = 3;
> x++
3
> x
4

Alessandro Candini  May 01, 2016 
Printed Page 206
Bottom third, below "The triple dot operator would also make sense for constructors"

The arguments passed to the new Date(...[2011, 11, 24]) indicate that the date should be November 24, 2011, but the the comment of the code snippet relates that the date should represent Christmas Eve (24/12).

Same goes for the following examples related to this date up until the example on the lower third of page 207, where the Date.construct() function result prints December while the argument is 11.

Anonymous  May 18, 2016