Errata

Refactoring JavaScript

Errata for Refactoring 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
Chapter 10
Extracting Functions into a Containing Object

I think the following paragraphs of descripting the typeerror is wrong, as I've debugged it in my local env:

TypeError: "listener" argument must be a function
This means that in the last line, getBody.getResult is not a function.

I think the error is not caused by "getBody.getResult is not a function", the reason is the "this" in the "result.on('data', this.saveBody);" statement is ClientRequest object instead of the getBody object, so "this.saveBody" will be undifined, that's why the error presented.

Lu  May 13, 2020 
PDF Page 126
Textbox at bottom of page, first paragraph

" Not only are those exam‐ ples as overused in tech books as the quote from Spiderman’s Uncle Ben, but also consider this passage from Gradus Ad Parnassum:"

Spiderman should be Spider-Man.

Alex Rinehart  Aug 21, 2019 
PDF Page 438
search for the word "rapscallions", bug is in code right below

Two mistakes:
- inner "return" omitted, so output = undefined
- naming the inner parameter "numberOne" overrides the partially applied outer parameter
so actual output:
add(1)(2) = 2 + undefined = NaN
rather than desired:
add(1)(2) = 2 + 1 = 3

The code:

/* original version */
function add(numberOne, numberTwo){
return function(numberOne){
numberOne + numberTwo;
};
};

/* corrected version */
function add(numberOne, numberTwo){
return function(numberTwo){
return numberOne + numberTwo;
};
};

Moises Baltazar  May 10, 2019