Errata

Learning JavaScript

Errata for Learning 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
Safari Books Online
Bitwise Operators (Chapter 5)

The const declarations for the Unix-style file permissions are missing the equals signs. Also their values are wrong: the correct values are 4 for read, 2 for write and 1 for execute.

Note from the Author or Editor:
Confirmed. This has been corrected in the text.

Demetrios Biskinis  Feb 20, 2016  Apr 15, 2016
Safari Books Online
Bitwise Operators (Chapter 5)

Testing for multiple flags requires a more complicated expression. Instead of let hasReadAndExecute = p & (FLAG_READ | FLAG_EXECUTE); it should be let mask = FLAG_READ | FLAG_EXECUTE; let hasReadAndExecute = (p & mask) === mask; Or rename the variable to hasReadOrExecute, but that is not likely to have been the intention.

Note from the Author or Editor:
Confirmed. This has been corrected in the text.

Demetrios Biskinis  Feb 20, 2016  Apr 15, 2016
Safari Books Online
Assignment Operators (Chapter 5)

In while loop, instead of using a comma in the condition use &&. Also, the interpolated expression in the last message is incorrect. See below: while((n = nums[i]) < 10 && i++ < nums.length) { console.log(`Number less than 10: ${n}.`); } console.log(`Number greater than 10 found: ${n}.`); console.log(`${nums.length - i} numbers remain.`);

Note from the Author or Editor:
Corrected in text.

Demetrios Biskinis  Feb 20, 2016  Apr 15, 2016
Safari Books Online
Third code example on The Error Object page

In The Error Object example, the console.error message is missing the closing backtick. console.error(`Error: ${validatedEmail.message}); should be console.error(`Error: ${validatedEmail.message}`);

Note from the Author or Editor:
Code samples corrected.

Norm Morrison  Apr 29, 2016  May 13, 2016
ePub
2nd paragraph. Just after the 'note'

'Vary' should be 'verify'. “You can verify this for any function f by typing f.prototype at the console.” Excerpt From: Brown, Ethan. “Learning JavaScript.” O'Reilly Media, Inc., 2016-03-01. iBooks. This material may be protected by copyright.

Note from the Author or Editor:
Corrected.

Leon Webster  Jun 13, 2016  Jun 19, 2018
Printed
Page xxi
first line, 3rd paragraph

"...readers of of my previous book..." should be only one "of"

Note from the Author or Editor:
This has been corrected.

Anonymous  Sep 09, 2016  Jun 19, 2018
Mobi
Page i
Preface, 2nd paragraph, 3rd sentence

Sentence begins "ES6 was developed quickly...." then goes on to state that Brenden Eich admits to getting a few things wrong "the first time". The sentence is referring to the first release of JavaScript, not ECMAScript 6. Sentence should begin "JavaScript was developed quickly..."

Note from the Author or Editor:
This has been corrected.

Anonymous  Sep 13, 2016  Jun 19, 2018
PDF
137

this snippet doesn't work properly // option 2: using "this" arg: arr.find(p => p.id === this.id, juliet); // returns juliet object

Note from the Author or Editor:
Corrected. This only works with a regular function (not an arrow function).

Anonymous  Jul 12, 2017  Jun 19, 2018
Safari Books Online
Chapter 4
3rd paragraph in “Additional for Loop Patterns”

“In this for loop, the condition will simply evaluate to undefined, which is falsy, meaning the loop will never have cause to exit.” If this were true, the body of the for loop would never execute. The condition of the for loop must evaluate as truthy or be empty for the loop to continue to execute.

Note from the Author or Editor:
The example is correct in that the loop will not terminate, but the reader is correct in pointing out the error in the explanation. When the condition is omitted altogether from a for loop, JavaScript assumes it to be true. The explanation has been updated accordingly.

Adrian Hempel  Nov 23, 2017  Jun 19, 2018
Safari Books Online
Table 5-7
Row 4

Bitwise XOR And Bitwise NOT both list "^" as their operator. Bitwise NOT needs to update to "~" (like in the example)

Anonymous  Dec 22, 2015  Feb 12, 2016
Safari Books Online
Before Table 5-10
Note

"Array destructuring doesn't only work on arrays: it works on any iteralbe" -> "iterable"

Anonymous  Dec 22, 2015  Feb 12, 2016
Safari Books Online
Before Table 5-10
After the note

"In these simple exmaples" -> "examples"

Anonymous  Dec 22, 2015  Feb 12, 2016
Safari Books Online
NA
3rd example under the headline "Variable Masking", Chapter 7 "Scope"

Says: console.log(z); // logs "5" Should say: console.log(z); // logs "3" z was never masked or changed in the example

Note from the Author or Editor:
This has been corrected.

Anonymous  Feb 15, 2016  Apr 15, 2016
Safari Books Online
Chapter 8, "Arrays and Array Processing", 1st example under "Adding or Removing Single Elements at the Beginning or End"

Says: let arr = ["b", "c", "d"]; arr.push("e"); // returns 4; arr is now ["b", "c", "d", "e"] arr.pop(); // returns "f"; arr is now ["b", "c", "d"] Should say: arr.pop(); // returns "e"; arr is now ["b", "c", "d"]

Note from the Author or Editor:
Corrected in text.

Anonymous  Feb 15, 2016  Apr 15, 2016
Safari Books Online
Chapter 8, "Arrays and Array Processing", 1st example under "Adding or Removing Elements At any Position"

Says: arr.splice(1, 2); // returns [2, 3, 4]; arr is now [1, 5, 6, 7] arr.splice(2, 1, 'a', 'b'); // returns [6]; arr is now [1, 5, 'a', 'b', 7] Should say: arr.splice(1, 2); // returns [2, 3]; arr is now [1, 4, 5, 6, 7] larr.splice(2, 1, 'a', 'b'); // returns [5]; arr is now [1, 4, 'a', 'b', 6, 7]

Note from the Author or Editor:
Corrected in text.

Anonymous  Feb 15, 2016  Apr 15, 2016
ePub
The Transcompilers Section.

Not truly a mistake on your part, but the Babel Transcompiler has evidently changed with a recent upgrade. http://babeljs.io/docs/setup/#babel_cli from site above: Note Pre-6.x, Babel enabled certain transformations by default. However, Babel 6.x does not ship with any transformations enabled. You need to explicitly tell it what transformations to run. The simplest way to do this is by using a preset, such as the ES2015 Preset. As a result the exercise you give in the book DOES NOT WORK. I was able to get it to partially work by adding .babelrc file in project directory. Add the following line to your .babelrc file: { "presets": ["es2015"] } However I think something else is still needed, at least for the CLI example, `Hello, ${name}, welcome to ES6!` does not print the value of name. Adding the code to a javascript file the string substitution worked.

Note from the Author or Editor:
This has been corrected in subsequent updates.

Tim Mitchell  Dec 19, 2015  Apr 15, 2016
PDF
Page 23
3rd paragraph

I'm not sure whether it makes a difference, but the Gulp documentation states that you should install gulp-cli, not gulp, globally: npm install -g gulp-cli

Note from the Author or Editor:
This has been corrected.

Anonymous  Apr 05, 2017  Jun 19, 2018
Printed
Page 23
inset at bottom of page

Linux/OSX instruction says "sudo install -g gulp"; should be "sudo npm install -g gulp"

Note from the Author or Editor:
This has been corrected.

Michael Tobis  Feb 15, 2018  Jun 19, 2018
ePub
Page 26
Source Code

Not an error, but it may help future readers to have the use of the backticks/grave accents explicitly pointed out for `{subject} {verb} {object}`. Due to my lack of critical examination of the code (my bad), I didn't realize why my ES6 test code was not working until I got to chapter 2. I could not copy and paste from the Kindle book and the source code is not yet available, otherwise this would not have been a problem. Thank you, Steve Mecca

Note from the Author or Editor:
Added clarifying note in code sample.

Anonymous  Apr 24, 2016  May 13, 2016
PDF
Page 28
Top of the page

The questions to the ESLint init have changed. I have installed version 2.5.1. The questions (and my answers) are below (I've added ** in front of questions that have changed**): ** ? How would you like to configure ESLint? Answer questions about your style ? Are you using ECMAScript 6 features? Yes ** ? Are you using ES6 modules? Yes ? Where will your code run? Browser #For some reason it showed browser whether I cose Node or browser. I couldn't get it to choose Node. ** ? Do you use CommonJS? No ? Do you use JSX? No ** ? What style of indentation do you use? Spaces ? What quotes do you use for strings? Double ? What line endings do you use? Unix ? Do you require semicolons? Yes ** ? What format do you want your config file to be in? JSON #They have added the option "Javascript" to JSON and YAML

Note from the Author or Editor:
Corrected in text.

Jim Wiedman  Mar 27, 2016  Apr 15, 2016
Printed
Page 28
3rd paragraph

'pouplar' should be 'pouplar'

Note from the Author or Editor:
Corrected.

Brian van den Broek  Apr 22, 2017  Jun 19, 2018
ePub
Page 37-38
second paragraph

The instructions to run " npm init " are lost In the following paragraph: As you install modules, you’ll want to keep track of them somehow; the modules you install (and use) are called dependencies of your project. As your project matures, you’ll want a concise way to know what packages your project depends on, and npm does this with a file called package.json . You don’t have to create this file yourself: you can run npm init , and interactively answer some questions (you can simply press Enter for each question and accept the defaults; you can always edit the file and change your answers later). Go ahead and do this now, and take a look at the generated package.json file. This should be called out as a step, otherwise the --save wlil not do anything.

Note from the Author or Editor:
Updated in text.

Guido  Mar 20, 2016  Apr 15, 2016
ePub
Page 38-39
second to last paragraph

The instruction to install gulp locally is lost in the following paragraph: You’ll only need to install Gulp globally once for each system you develop on. Then, for each project, you’ll need a local Gulp, so from your project root, run npm install --save-dev gulp (Gulp is an example of a dev dependency: your app won’t need it to run, but you’ll use it to help with your development process). Now that Gulp has been installed, we create a Gulpfile ( gulpfile.js ):

Note from the Author or Editor:
Corrected in text.

Guido  Mar 20, 2016  Apr 15, 2016
PDF
Page 46
After second paragraph of Objects section

The line ' obj.color; ' should probably be ' obj.color = "yellow" ' in order to match the commented result value of "yellow" since the color property isn't initialized to that value.

Note from the Author or Editor:
The code example was updated to be more clear.

Anonymous  May 05, 2016  May 13, 2016
PDF
Page 47
Object example "sam3".

"subfaimily" in the object sam3 classification should be "subfamily".

Note from the Author or Editor:
This has been corrected.

Dercilio Alves Fontes  Apr 13, 2018  Jun 19, 2018
PDF
Page 48
top of page

sam3.classification.family; // "Felinae" sam3["classification"].family; // "Felinae" sam3.classification["family"]; // "Felinae" sam3["classification"]["family"]; // "Felinae "Felinae" should be 'Felidae', per the value declaration at bottom of page 47

Note from the Author or Editor:
Sharp eye, thank you Bob! This has been corrected.

Anonymous  Apr 01, 2016  Apr 15, 2016
ePub
Page 54
1st paragraph

“From here on out, when you install local packages, you should add either the --save or --saveDev flag" from looking at npm documentation this should be "--save-dev" instead of "--saveDev"

Note from the Author or Editor:
Corrected in text.

Anonymous  Feb 01, 2016  Apr 15, 2016
ePub
Page 56
last paragraph

says "On Linux and OSX, look in your programs for the Termainal program" should say "On Linux and OSX, look in your programs for the Terminal program"

Terry Bush  Jan 22, 2016  Feb 12, 2016
Printed, PDF, ePub
Page 59
while loops

Condition = funds > 1. The previous pages discuss the sailor playing until broke, ie funds > 0, but page 59 onwards has funds > 1 therefore if the sailor has 1 pence left the game is over but he isn't broke.

Note from the Author or Editor:
Corrected.

Anonymous  Jul 03, 2016  Jun 19, 2018
PDF
Page 82
unary plus example

const p1 = -x1*1; const p2 = +x2*2; const p3 = +x3*3; const p3 = -x4*4; Should the last one be "const p4"?

Note from the Author or Editor:
Corrected.

Dercilio Alves Fontes  Apr 18, 2018  Jun 19, 2018
PDF
Page 83
first paragraph

In "For example, 10 % 3.6 will be 3 (3.6 goes into 10 twice, with 2.8 left over).", the first expression should be "10 % 3.6 will be 2.8".

Note from the Author or Editor:
Corrected.

Dercilio Alves Fontes  Apr 18, 2018  Jun 19, 2018
PDF
Page 91
Paragraph with "The second line ..."

"The second line in that example ..." should be "The third line in that example ...".

Note from the Author or Editor:
Corrected.

Dercilio Fontes  Apr 21, 2018  Jun 19, 2018
PDF
Page 101
First paragraph of conclusion

"basic building blacks" should be "building blocks"

Note from the Author or Editor:
Fixed this very embarrassing typo!

Anonymous  May 09, 2016  May 13, 2016
Printed, PDF, ePub
Page 105
Top of page - array description

After changing arr[1] the text describes the array as: // arr is now [1, function getGreeting(), 2] when it should be // arr is now [1, function getGreeting(), 3]

Note from the Author or Editor:
Corrrected.

Anonymous  Jul 03, 2016  Jun 19, 2018
PDF
Page 118
Last line on page

"aways" should be "always"

Note from the Author or Editor:
Corrected.

Anonymous  May 11, 2016  Jun 19, 2018
Printed
Page 118
2nd Example, roughly middle of page

Example is putting user information in a single object: let user = { name = "Irena", age = 25, }; results in SyntaxError: Invalid shorthand property initializer should be... let user = { name: "Irena", age: 25, };

Note from the Author or Editor:
This has been corrected.

Brandon Anderson  Jan 28, 2017  Jun 19, 2018
PDF, ePub
Page 119
the example discussed at the end of the section "Lexical Versus Dynamic Scoping"

According to the text, the second invocation of console.log in function f should cause a crash, because y, the argument passed to console.log, isn't in scope inside the body of f. I've tried running that example with node, the Firefox console, and the Safari console, and I don't see a crash. Instead, I see the following output: 3 3

Note from the Author or Editor:
Corrected in text.

rhanneken  Mar 14, 2016  Apr 15, 2016
Printed
Page 119
1st code snippet

I get NO error when running the following code snippet even though the comment in the book says I should: const x = 3; function f() { console.log(x); // this will work console.log(y); // THIS WILL CAUSE A CRASH } const y = 3; f(); Even if I invoke the function f before the assignment to y, I just get 'undefined' printed out from console.log(y). That is, no CRASH. Can you clarify what was meant by THIS WILL CAUSE A CRASH? Thanks in advance!

Note from the Author or Editor:
This example was incorrect; the example in the text has been corrected.

Anonymous  Sep 20, 2016  Jun 19, 2018
Printed
Page 123
First code example under "Function Scope and Hoisting"

The example: let var 1; let var 2 = undefined; var 1; //undefined var 2; //undefined undefinedVar; //ReferenceError: notDefined is not defined Ironically, I think notDefined is not mentioned, and should probably be undefinedVar.

Note from the Author or Editor:
Ironic indeed. This has been corrected from a previous errata.

Dylan Zwick  Nov 28, 2017  Jun 19, 2018
Printed
Page 123
Second paragraph under "Function Scope and Hoisting"

What is the world does the sentence: "When you declare a variable with var, it's available everywhere in the current scope.. even before it's declared." even mean?!? That's an almost comically confusing sentence. When you declare a variable with var is that variable not yet declared?

Note from the Author or Editor:
This is comically confusing. But variable hoisting is one of the comically confusing parts of JavaScript. I did change the wording to say "*above* where its declared" to try not to conflate location in the file with human temporal concept.

Dylan Zwick  Nov 28, 2017  Jun 19, 2018
PDF
Page 125
Second code example

"undefinedVar" in the code example is a different name than the variable "notDefined" stated in the comment

Note from the Author or Editor:
Corrected.

Anonymous  May 11, 2016  Jun 19, 2018
Printed
Page 129
Second paragraph

After pointing out that JS arrays can be nonhomogeneous, it is claimed that "it follows from this that arrays can have other arrays as elements". It does not follow. A language which allowed only numbers and strings to be placed in array and allowed a given array to contain elements of both types would have nonhomogeneous arrays, but would not allow arrays to be elements of arrays. Likewise, a language could enforce that in an array all elements must be of the same type while allowing an array all the elements of which were themselves arrays.

Note from the Author or Editor:
Corrected.

Brian van den Broek  Apr 23, 2017  Jun 19, 2018
PDF
Page 131
Example: array literals

const arr4 = [ { name: "Fred", type: "object", luckyNumbers = [5, 7, 13] }, ... ]; Should be "luckyNumbers: [5, 7, 13]" with colon (:) for key : value in a object.

Note from the Author or Editor:
Corrected.

Dercilio Alves Fontes  May 16, 2018  Jun 19, 2018
Printed
Page 132
Fourth sentence

In "up to the end of the string", 'string' should be 'array'.

Note from the Author or Editor:
Corrected.

Brian van den Broek  Apr 23, 2017  Jun 19, 2018
PDF
Page 133
Tip at the bottom of the page

The tip states that the k words would be in their original order. However, according to the documentation on MDN sort isn't necessarily stable. Hence isn't the order of k words undefined?

Note from the Author or Editor:
After investigating, I've concluded that the reader is correct. I have not been able to find a JavaScript implementation or situation where the sort was not stable, but the specification does indeed not guarantee that. I have updated the text accordingly.

Anonymous  Apr 16, 2017  Jun 19, 2018
PDF
Page 135
Last paragraph

The text states that find returns null, if no element was found, but it actually returns undefined.

Note from the Author or Editor:
This has been corrected.

Anonymous  Apr 16, 2017  Jun 19, 2018
Printed
Page 136
3rd paragraph

Sentence is "find and findIndex are great if you're looking for the index of an element." Should be "indexOf" instead of "find" (find returns the element that is searched for).

Note from the Author or Editor:
Corrected.

Anonymous  Feb 13, 2017  Jun 19, 2018
Printed
Page 136
3rd paragraph

"Does your array contain functions and you need promises?" As promises have yet to be introduced at this point, the example is not well chosen.

Note from the Author or Editor:
Corrected.

Brian van den Broek  Apr 23, 2017  Jun 19, 2018
Printed
Page 138
2nd code snipped, last line

names.map(String.toLowerCase) results in error: TypeError: undefined is not a function

Note from the Author or Editor:
This has been corrected.

Anonymous  Sep 20, 2016  Jun 19, 2018
PDF
Page 139
Last paragraph

' "A", "J", "Q", and "Q" ' should be ' "A", "J", "Q", and "K" '

Note from the Author or Editor:
Corrected.

Anonymous  Jun 28, 2016  Jun 19, 2018
PDF
Page 140
Numerous

Multiple mentions of callback, but it's a concept not introduced until page 200. Either a forward reference or some other clarification is needed.

Note from the Author or Editor:
Added note with forward reference to Chapters 13 and 14.

Dario Strbenac  Jun 01, 2016  Jun 19, 2018
Printed
Page 148
1st code snippet

The fourth property, SYM, is not logged out in the For..In loop below. Why not? Is that expected? Thanks in advance. const SYM = Symbol(); const o = { a: 1, b: 2, c: 3, [SYM]: 4 }; for(let prop in o) { console.log(`${prop}: ${o[prop]}`); }

Note from the Author or Editor:
The text has been clarified by stating that for...in does not include symbol properties.

Anonymous  Sep 20, 2016  Jun 19, 2018
Printed
Page 149
last code listing

In the set definition: this._userGear = vaule; should be this._userGear = value;

Note from the Author or Editor:
This has been corrected.

David Powers  Jul 19, 2016  Jun 19, 2018
Printed
Page 151
last paragraph of code

The code example says: get userGear() {...} set userGear(value) {...} There is no explanation to the 'get' and 'set' syntax prior to declaring the method. A clarification on how 'get' and 'set' works would be helpful before the example.

Note from the Author or Editor:
Added clarifying copy.

Ron Itelman  May 26, 2016  Jun 19, 2018
Printed
Page 159
Last sentence of Chapter 9, section "Enumerating Object Properties, Revisited"

"... using Object.keys, which includes only properties defined on the prototype." This is the exact opposite of what the author meant. It should be something like: "... using Object.keys, which includes only properties defined on the object, and does not include properties defined on the prototype."

Note from the Author or Editor:
Corrected.

Chris Janicki  Aug 13, 2017  Jun 19, 2018
PDF
Page 160

InsurancePolicy class definition is followed by parentheses: class InsurancePolicy() {} which will produce the following error: Uncaught SyntaxError: Unexpected token (

Note from the Author or Editor:
Corrected.

Eduardo Hernandez  May 03, 2018  Jun 19, 2018
PDF
Page 175
Second last line

"... done, which becomes false after you read the last page." should use true instead of false. It currently contradicts the example of page 176.

Note from the Author or Editor:
Corrected.

Dario Strbenac  Jun 01, 2016  Jun 19, 2018
PDF
Page 182
const it = count()

Chapter 12, generators and return, p182 function* abc (){} const it = count(); It should be: const it = abc();

Note from the Author or Editor:
Corrected.

Anonymous  May 11, 2016  Jun 19, 2018
Printed
Page 182
Both code samples (and the ones​ on the next two pages, as well)

The top level if clause of the function uses '!==' while the nested if clauses use '!='. There is no reason for the difference given, and, as far as I can tell, it does not really make a difference. But, isn't it suboptimal style to switch between the two different inequality tests in a single context where each test is serving a very similar role?

Note from the Author or Editor:
Corrected. There is no reason for these to use loose equality; it was just a typo.

Brian van den Broek  Apr 24, 2017  Jun 19, 2018
Printed
Page 189
Second paragraph

"this section is something beginners often struggle with" Should be "the subject matter of this section . . . " or something similar.

Note from the Author or Editor:
Corrected.

Brian van den Broek  Apr 25, 2017  Jun 19, 2018
PDF
Page 190
1st code snippet, 2nd code snippet, code snippet in the Figure 13-1

There is an error in the code. The '>' sign in the for-loop should be replaces with '>='. It holds for each code snippet presented on the page. Existing loop: for(let i=5; i>=0; i--) { ... } Corrected loop: for(let i=5; i>=0; i--) { ... } Otherwise we will never get it going! PS: same holds for the first code snippet on the page 191

Note from the Author or Editor:
This has been corrected.

Vitaliya Alisauskaite  Mar 04, 2018  Jun 19, 2018
PDF
Page 197
code snippet, recursive function calculating factorial

current version: function fact(n) { if(n === 1) return 1; return n * fact(n-1); } mathematically correct version function fact(n) { if(n === 0) return 1; return n * fact(n-1); }

Note from the Author or Editor:
This has been corrected. I believe I originally left out the special case of 0! thinking that it would be unnecessarily confusing, but in retrospect, I see that was the wrong decision!

Vitaliya Alisauskaite  Mar 04, 2018  Jun 19, 2018
ePub
Page 205
2nd paragraph. Just after the 'note'

'Vary' should be 'verify'. “You can verify this for any function f by typing f.prototype at the console.” Excerpt From: Brown, Ethan. “Learning JavaScript.” O'Reilly Media, Inc., 2016-03-01. iBooks. This material may be protected by copyright.

Note from the Author or Editor:
Corrected.

Leon Webster  Jun 13, 2016  Jun 19, 2018
PDF
Page 214
1st paragraph

First paragraph refers to chapter 6 "As you learned in Chapter 6, generators that call yield" but it was in Chapter 12 not 6.

Note from the Author or Editor:
Corrected.

Eduardo Hernandez  May 13, 2018  Jun 19, 2018
Printed
Page 215
Final paragraph

"If your only programming experience is with languages that have synchronous semantics, learning synchronous programming the JavaScript way can be daunting..." Surely this should be: "If your only programming experience is with languages that have synchronous semantics, learning asynchronous programming the JavaScript way can be daunting..."

Note from the Author or Editor:
Typo corrected.

David Powers  Jul 19, 2016  Jun 19, 2018
ePub
Page 219
1st paragraph

"Unless you are on UTC (hello, Timbuktu, Madrid, and Greenwich!)," Madrid time zone is not UTC, is UTC+1 or UTC+2 in summer time

Note from the Author or Editor:
Corrected in text.

Inaki Rodriguez Carasa  Mar 16, 2016  Apr 15, 2016
Printed
Page 222
Last line of code listing

The final line of code uses toLocaleFormat(), which is a nonstandard method of the Date object that requires a format string. No format string has been supplied as an argument, so this wouldn't work even if the method is supported by the browser. The standard method to display the date and time formatted for the local time zone and conventions is toLocaleString(). Also the time displayed is incorrect. The offset from UTC is -7 hours, so it should be 5 PM. d.toLocaleFormat() // "5/9/1930 4:00:00 PM" should be d.toLocaleString() // "5/9/1930 5:00:00 PM"

Note from the Author or Editor:
This has been corrected; "toLocaleFormat" example removed. No one should be using that!

David Powers  Jul 19, 2016  Jun 19, 2018
PDF
Page 223
7 paragraph Transmitting Dates

after.d instdanceof date // false Remove d after.d inst(d)anceof date // false

Note from the Author or Editor:
Corrected.

Anonymous  May 24, 2016  Jun 19, 2018
PDF
Page 223
code on Transmitting Dates

const before = { d: new Date() }; before.d instanceof date --> instance of Date (); --> capital letter const json = JSON.stringify(before); const after = JSON.parse(json); after.d instdanceof date --> inst(d)ance of Date (); --> capital letter, remove d on instance. typeof after.d

Note from the Author or Editor:
Corrected.

Anonymous  May 24, 2016  Jun 19, 2018
Printed
Page 223
First line of code

Time is wrong. The offset from UTC is -7 hours, so d.toLocaleTimeString() // "4:00:00 PM" should be d.toLocaleTimeString() // "5:00:00 PM"

Note from the Author or Editor:
This has been corrected.

David Powers  Jul 19, 2016  Jun 19, 2018
Printed
Page 223-4
Date Components code example

The example uses a date in October 1815, and displays the results someone would see in Los Angeles. I can't test this myself because I'm based in London. However, d.getHours() shows the result as 17, which indicates that JavaScript is assuming a -7 hour offset from UTC. California didn't adopt daylight saving time until 1949. Does this mean that JavaScript applies DST offsets to historical dates regardless of whether DST was in force at that time? Maybe a better example would be to use a more recent date.

Note from the Author or Editor:
This is incredibly detailed errata! And totally correct. I've updated the text with a comment that you shouldn't rely on JavaScript to know when DST was adopted in various parts of the world.

David Powers  Jul 19, 2016  Jun 19, 2018
ePub
Page 228
3rd paragraph

"const x = 3800.5; x.toExponential(4); // "3.8005e+4"; x.toExponential(3); // "3.801e+4"; x.toExponential(2); // "3.80e+4"; x.toExponential(1); // "3.8e+4"; x.toExponential(0); // "4e+4";" All of them should read e+3 instead of e+4

Note from the Author or Editor:
Corrected in text.

Inaki Rodriguez Carasa  Mar 16, 2016  Apr 15, 2016
Printed
Page 237
Penultimate paragraph

We'll start with a simple example--replacing all four-letter words. should be We'll start with a simple example--replacing all words that contain at least four letters. The regex /\w(4,}/ig also matches "going" and "Saint", both of which contain five letters.

Note from the Author or Editor:
This has been corrected.

David Powers  Jul 20, 2016  Jun 19, 2018
PDF
Page 247
1st code example in section "Backreferences"

Non-capturing groups don't seem to work for the example, so that the regular expression should rather be /([A-Z])([A-Z])\2\1/g.

Note from the Author or Editor:
This has been corrected.

Anonymous  Apr 22, 2017  Jun 19, 2018
Printed
Page 248
Final paragraph

The backtick and single straight quote following the dollar sign have been replaced in the descriptive text with a left and right curly quote respectively. The token for everything before the match should be $` The token for everything after the match should be $' The correct characters are used in the monospace code that follows.

Note from the Author or Editor:
Corrected.

David Powers  Jul 20, 2016  Jun 19, 2018
PDF
Page 265
Middle

The text explains "We’ve called our data attributes action and contains ...", however the code uses containing.

Note from the Author or Editor:
Corrected.

Dario Strbenac  Jun 01, 2016  Jun 19, 2018
Printed
Page 282
General note

The note after the code listing says "The exports shorthand only works for exporting objects; if you want to export a function or some other value, you must use module.exports." The second part of the sentence is incorrect on two counts: * A function is an object. * The preceding code listing shows the exports shorthand being used to export functions. When tested, the code works as expected. The first sentence of the note should be revised along the following lines: "The exports shorthand works only for exporting functions or other objects; if you want to export some other value, you must use module.exports."

Note from the Author or Editor:
I can see how this footnote is confusingly worded, but this errata is not correct. You can certainly use the "exports" shorthand to export functions that are properties of the export object, but that is not the same as exporting a (single) function from the module; you're still exporting an object that just happens to contain function properties. As for functions being objects, that's true, but that's an implementation detail, and for practical intents and purposes objects are objects and functions are functions. I did, however, clean up the language to be more precise and clear.

David Powers  Jul 24, 2016  Jun 19, 2018
PDF
Page 286
Table 20-2

Description of URL module should read "URL parsing utilities" instead of "URL prasing utilities".

Note from the Author or Editor:
Typo corrected.

Anonymous  Jul 05, 2016  Jun 19, 2018
Printed
Page 295
last paragraph

The second sentence in the final paragraph on page 295 refers to the ServerRequest object (often abbreviated res), but later references in the same paragraph call it the ServerResponse object. Since res is a more likely abbreviation of ServerResponse than ServerRequest, should the first reference also be ServerResponse? The same paragraph also refers to the IncomingMessage object, but the second paragraph on page 296 calls it IncomingRequest. Which is correct?

Note from the Author or Editor:
This has been corrected.

David Powers  Jul 24, 2016  Jun 19, 2018
PDF
Page 304
We’ll add name and greet properties to obj: [...]

Object.defineProperty(obj, 'color', { get: function() { return this.color; }, set: function(value) { this.color = value; }, }); // ERROR: maximum call stack size exceeded (recursive function) // SOLUTION: Object.defineProperty(obj, 'color', { get: function() { return this.__color; }, set: function(value) { this.__color = value; }, });

Note from the Author or Editor:
Corrected.

Anonymous  Jun 28, 2016  Jun 19, 2018
PDF
Page 305
Lastly, there is also a Object.defineProperties (note the plural) ....

object.defineProperties(object, descriptors) Descriptor should be an object {}. const arr = [3, 1.5, 9, 2, 5.2]; Object.defineProperties(arr, { // missing curly brace sum: { value: function() { return this.reduce((a, x) => a+x); }, enumerable: false }, // without Parentheses avg: { value: function() { return this.sum()/this.length; }, enumerable: false } // without Parentheses }); // missing closing curly brace console.log(`${arr.sum()}`); // 20.7 console.log(`${arr.avg()}`); // 4.14

Note from the Author or Editor:
Corrected.

Anonymous  Jun 28, 2016  Jun 19, 2018
PDF
Page 307
code: Object.isExtensible(log2);

Object.isExtensible(log2); // true // Logs false. Object.isExtensible(log2); // false

Note from the Author or Editor:
Corrected.

Anonymous  Jun 29, 2016  Jun 19, 2018
Mobi
Page 827
Linting

.eslintrc file => . eslintrc.js file

Note from the Author or Editor:
Corrected.

kamimura  Jun 30, 2016  Jun 19, 2018
Mobi
Page 2869
1st paragraph

Mobi location 2869 6. Functions -- Function Arguments -- Do Arguments Make the Function? "For example, in C, f() (no arguments) is a different function than f(x) (one argument), which is a different function than f(x, y) (two arguments)." C does not support function overloading in the traditional sense (C11 added the _Generic keyword, which allows you to emulate function overloading with the help of the preprocessor) [1]. Suggest changing this sentence to a language that does support function overloading, such as C++ or Java, to avoid confusing new programmers.

Note from the Author or Editor:
This is a fair point; while the wording is technically correct, it does imply that if C did not include the signature, you could have two functions named f, which is not correct. I have changed the example to use C++, per the reader's suggestion.

Anonymous  Sep 23, 2016  Jun 19, 2018