Errata

JavaScript Enlightenment

Errata for JavaScript Enlightenment

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
X
Second live code example

http://my.safaribooksonline.com/book/programming/javascript/9781449344412/2dot-working-with-objects-and-properties/host_objects_vs_native_objects_html

Live Code
<!DOCTYPE html><html lang="en"><body><script>

for (x in window.document) {
console.log();
}

should be

for (x in window.document) {
console.log(x);
}

Note from the Author or Editor:
Page 42 of pdf and print. the second console.log() is missing the "x". It should be:

console.log(x); not console.log();

David Abernethy  Dec 26, 2012 
PDF
Page 15-16
United States

The console.log output (and the descriptive text and code comments) for the objects created using the constructor function indicates the RegEx constructor would be "function." Using Chrome or Safari on a Mac yields "object" as the result.

I'm unsure if this is an error or simply an artifact of the Javascript implementations for those browsers.

P.S. Loving the book...especially the Live Code to JSFiddle!

Note from the Author or Editor:
on page 16

typeof myRegExp, // BE AWARE typeof returns function for RegExp()

change to:

typeof myRegExp, // BE AWARE typeof returns object for RegExp()

Bob Monsour  Jan 10, 2013 
PDF
Page 18
second half of code example

The book has:

// logs "string string"

console.log(primitiveString1.toString(), primitiveString2.toString());

// logs "number number"
console.log(primitiveNumber1.toString(), primitiveNumber2.toString());

// logs "boolean boolean"

console.log(primitiveBoolean1.toString(), primitiveBoolean2.toString());

The actual log outputs are "foo foo", "10 10", and "true true" respectively, not "string", "number", and "boolean". Perhaps I'm just reading the example wrong?

Note from the Author or Editor:
comments should read, like this:

//logs "foo" "foo"
console.log(primitiveString1.toString(), primitiveString2.toString());

// logs "10" "10"
console.log(primitiveNumber1.toString(), primitiveNumber2.toString());

// logs "true" "true"
console.log(primitiveBoolean1.toString(), primitiveBoolean2.toString());

Not

// logs "string string"
console.log(primitiveString1.toString(), primitiveString2.toString());
// logs "number number"
console.log(primitiveNumber1.toString(), primitiveNumber2.toString());
// logs "boolean boolean"
console.log(primitiveBoolean1.toString(), primitiveBoolean2.toString());

Michael Blyth  Jan 09, 2013 
PDF
Page 23
United States

The statement...

console.log(typeof myRegExp); // logs function? WHAT? Be aware...

This actually logs as an object in Chrome. This is similar to an earlier errata that I posted regarding a similar note.

Note from the Author or Editor:
page 23

console.log(typeof myRegExp); // logs function? WHAT? Be aware...

should be:

console.log(typeof myRegExp); // logs object? WHAT? Be aware...

Bob Monsour  Jan 10, 2013 
Printed, PDF, ePub
Page 31
Code

In the code snippet starting at p. 31, in the console.log() parts, myObject.myNull and myFunction.myNull are logged twice.

Note from the Author or Editor:
remove the duplicated text found in the console.log() code on page 31 and 32. There should be only one of each.

Remove one of the:

myObject.myNull,

and

myFunction.myNull,

Demetris Kikizas  Jan 25, 2013 
PDF
Page 50
Code at top of page

When I run the code using the Live Code link, JSFiddle doesn't open the console panel to show the result. I've run all of the code examples so far and this is the first one that has done it.

I opened one of the other examples that does open the console panel and pasted the code in to verify the result.

Strange...

Note from the Author or Editor:
need to think on this, as firebug lite fails to focus the console panel when Object.prototype has a property added to it.

Bob Monsour  Jan 11, 2013 
Printed, PDF, ePub
Page 69
Live Code link at top of page

The Live Code links starting on this page are using jsbin rather than jsfiddle. I was surprised and unsure if this is what you intended.

Note from the Author or Editor:
update the live code link to be:

http://jsfiddle.net/javascriptenlightenment/vpnen/

Bob Monsour  Jan 11, 2013 
Printed, PDF, ePub
Page 843
United Kingdom

In the Kindle version (location 843, no page numbers!) the note reads "Keep in mind that, besides their own properties, instances can have properties inherited from the prototype chain. Or, as we just saw in the code, properties added to the constructor after instantiation. This highlights the dynamic nature of objects in JavaScript."

I cannot see that this has been demonstrated at all at this point. Several related issues have been explained but there is not yet any example that shows an instance inheriting properties added to the constructor after instantiation. (If this has been demonstrated and I've missed it, this is perhaps not the right place for the note.)

Note from the Author or Editor:
Change:

"Keep in mind that, besides their own properties, instances can have properties inherited from the prototype chain. Or, as we just saw in the code, properties added to the constructor after instantiation. This highlights the dynamic nature of objects in JavaScript."

to:

"Keep in mind that, besides their own properties, instances can have properties inherited from the prototype chain. Or, as we just saw in the code, properties added to the instance after instantiation. This highlights the dynamic nature of objects in JavaScript."

William Hudson  May 16, 2013 
Printed, PDF, ePub
Page 1408
United Kingdom

At location 1408 in Kindle, the comment for funcC mentions 'too.method()' for no apparent reason.

Note from the Author or Editor:
The comment on page 54 in pdf

// too.method() or funcC['method']()

should be changed to

// funcC.method() or funcC['method']()

William Hudson  May 17, 2013