Errata

You Don't Know JS: this & Object Prototypes

Errata for You Don't Know JS: this & Object Prototypes

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
PDF Page 26
main code snippet

The final line of the code snippet should read:

baz.val; // "p1p2"

Timea Bálint  Aug 29, 2018 
Printed Page 32
first line on page 32

function foo() {
return (a) => {
console.log(this.a);
};
}

var obj1 = {
a:2
}

var obj2 = {
a:3
}

var bar = foo.call(obj1);
bar.call(obj2); // 2, not 3!

The point here is that this returned arrow function will inherit the lexical this from function foo.

What I do not understand is why the input for this arrow function above is a?

I removed the 'a' from the arrow function and this example still works as expected.
When the arrow function is called via references, they are called with no input arguments.
What is the point of having 'a' as the input to the arrow function?

Yu Zhang  Mar 31, 2020 
Printed Page 82
source code

Page:82, in the code

method car.drive = function() missing the en-closing curly braces "}"

Karmegam  Oct 30, 2020 
Printed Page 88
Scenario number 1 for myObject.foo = "bar" assignment when foo not in myObject

There are three scenarios for the myObject.foo = "bar" assignment when foo not in myObject (fifth paragraph)

In that, the description for first scenario need some correct as following.

Instead the text
not marked as read-only (writable:false)

It shall be
not marked as read-only (writable:true)




Karmegam  Oct 30, 2020