By Developers, For Developers

Historical errata for Rediscovering JavaScript

PDF PgPaper PgTypeDescriptionFixed onComments
8TYPO

“The code does not produces the intended or desired output, but instead outputs”

should read -

“The code does not produce the intended or desired output, but instead outputs”

2018-03-04
10SUGGEST

“Let’s first create a sample script with a few smelly code in it:”

This reads badly, should be rewritten. Perhaps “…a sample script with some smelly code in it”, or simply, “…some badly written code in it”.

2018-03-04
11TYPO

“Once you’ve install ESLint”

should read -

“Once you’ve installed ESLint”

2018-03-04
71TYPO

Near the bottom of the page “arror” should be “arrow”

2018-03-04
245TYPO

“since both have a minimual impact on memory usage.”

should be:

“since both have a minimal impact on memory usage.”

2018-03-13
61TYPO

In flowchart - “returned object’s done is true?” - true and false branches are the wrong way round. Done = true should end the iteration.

2018-03-13
73TYPO

“drop the parenthesis” => " drop the parentheses" since it’s referring to “(”and “)” but not the entire phrase “(subject)”

2018-03-13
111ERROR

Hi, I believe that in the context of destructuring, page 111 and 112, it is the “spread” operator that saves the day - not the “rest”. The code is correct, as (you know), these two look the same but are used in different contexts..

2018-03-13
58ERROR

In the script fragment, the for loop reads:
In the script fragment iterators/search.js:

for(const superHero of superHeroes) {
console.log(`Result of search: ${names.search(superHero)}`);
}

This was confusing upon reading, and indeed does not work for me. I’m not expert, but rationalizing about it, should it be something more like:

for (const superHero of superHeros) {
console.log(‘Result: ’ + superHero[Symbol.search](names));
}

2018-04-02Hi Richard, \n \n \nThank you for reporting. There are backticks in the code, one right after ( and one right before ) on the console.log() line. Without the backticks, the code will not work. \n \n \nCould you please take a look at the code when you get a chance and confirm it works with the backticks? \n \n \nThanks \n \n \nVenkat
195ERROR

For the solution to chapter 8, exercise 5, the base class should probably be:

`class SpecialWorkChecker {
isSpecial(word) { return word !== word; }
}

Otherwise, the “isSpecial” solutions for PalindromeChecker and AlphabeticalChecker will always return true.

This should probably be fixed on page 157, as well.

Also, should this class be named “SpecialWordChecker” instead of “SpecialWorkChecker”?

Finally, all lines processing ‘abe’ should probably say ‘abe’ in the trailing comments.

As a suggestion, you could destructure “word” for the solutions for PalindromeChecker and AlphabeticalChecker instead of calling “word.split()”. For example:

class PalindromeChecker extends SpecialWorkChecker {
isSpecial(word) {
return word === […word].reverse().join(’’) || super.isSpecial(word);
}
}

2018-04-01
25TYPO

Last paragraph, 4th sentence: change “… you can rely instead OF the language feature to limit scope.” to “… rely instead ON the …”.

Actually I prefer “… rely instead on language features …” since we are talking about let, const, modules, and I guess objects, too.—George S. Cowan

2018-04-08
26TYPO

“code is easier to reason” -> “code is easier to reason about”

2018-04-08
186175TYPO

Last sentence of second paragraph begins “A code that returns a promise”. In the context of programming, “code” is an uncountable noun; it should just read “Code that returns a promise”.

197186TYPO

Second paragraph, first sentence: “The all() static method of promise”.. that should be “Promise” styled as a class name.

71TYPO

“This all means means”

57TYPO

“To retrieve date, use the get() method”. Should be data instead of date.

278ERROR

When I run the code in the browser, outer calls inner. Because “i” isn’t set as “const” or “let”, it becomes a global variable.

The book says that that value goes to 5 when it runs. Once it returns to outer, the value is above 3 so it only prints 1 thru 5 once
however,
When I run the code, the actual value of “i” after running inner is 6, not 5

You can check this value by adding an additional console.log() command.

I have the code printed below from chrome’s console:

const outer = function () {
for (i = 1; i <= 3; i) {
inner();
}
};

const inner = function () {
for (i = 1; i <= 5; i) {
console.log(i);
}

console.log(i);
};
undefined
outer();

238ERROR

[before, after = 0] = beforeAndAfter(0);
console.log(`${before} and ${after}`); //0 and 1

The answer for this is incorrect. With the code the is given the result is 1 and 0. The first line needs to be changed to:
[after, before=0] = beforeAndAfter(0);
to get the answer given.

237SUGGEST

In the answer, the line
return `${texts[index]}${expression.toString().toUpperCase()}`;
could just as well have been written as
return `${texts[index]}${expression..toUpperCase()}`;
since ‘expression’ is already a string. It seems to me that the addition of “toString()” is adding confusion.

237SUGGEST

Maybe in the next edition, the answer to exercise 5 can be changed to
console.log(numbers.filter(num => num % 2 === 0).reduce((total,num) => total + num * 2,0));
The inclusion of your second step of .map() to me seems to be adding additional confusion. My solution does require that the second parameter to the reduce function be zero to give the correct answer and that, in itself, could cause confusion.

132TYPO

In the last sentence of the paragraph before the “Wrapping Up” section, there is an “s” where it shouldn’t be. The sentence reads:
“sIf the objects gotta go, they gotta go — weak collections don’t prevent that.”
The “s” at the beginning of this sentence needs to be removed.

185TYPO

The last bulleted item states “Then then-catch syntax …” which I believe should be “The then-catch symtax …”

231TYPO

Exercise 3 solution. The text says “Runs the code in struct mode”. It should say “strict”, rather than “struct”.

80TYPO

For the card deck, one of the suits is spelled ‘Spaces’ instead of ‘Spades’. Maybe this is intentional, or maybe not.
Enjoying the book!

175ERROR

“Calls to functions that return promises are nonblocking. The control will immediately flow to the next statement.” That’s not true, here is a counter-example:

const returnPromise = function () {
return new Promise(function (resolve) {
for (let i = –2000000000; i < 2000000000; i) ;
resolve(‘DONE’);
})
};

const promise = returnPromise();
console.log(promise);

If the sentence was true, ‘Promise { }’ would be printed immediately, but it isn’t.

175ERROR

“Since the calls are asynchronous…”

The call aren’t asynchronous, the messages will always be printed in the same order. This can be verified by placing ‘while(true);’ statements in different locations of the program. For example, if the result for the first promise can’t be printed due to such a statement, the result (i.e. the error) of the second promise is never printed.

217ERROR

“It turns out that Map.prototype’s prototype is an empty object.” It’s not… It’s prototype is Object.prototype. Thus the following code prints “true”.

console.log(Reflect.getPrototypeOf(Map.prototype) === Object.prototype)

And by replacing the prototype of Map.prototype, this code leads to an error:

const proxy = new Proxy(Map.prototype, {
get(target, p, receiver) {
return receiver.get(p);
}
});

console.log(languagesAndAuthors.toString());
Reflect.setPrototypeOf(Map.prototype, proxy);
console.log(languagesAndAuthors.toString());

8972TYPO

Typos near bottom of page in navigator.geolocation.getCurrentPosition: two instances of “innherHTML” should be “innerHTML”

Categories: