getify / You-Dont-Know-JS

A book series on JavaScript. @YDKJS on twitter.
Other
178.87k stars 33.44k forks source link

Update chapter 2 #1592

Closed Lafaa closed 4 years ago

Lafaa commented 4 years ago

In the declaration of the class "Book" you declared the constructor to accept an Object with 3 properties (title, author, publishedOn), but then when you instanciate that class, you use the 3 values not wrapped into an object. Since in all the rest of the examples you did not use wrapping objects, I think it's best to correct the class declaration instead of fixing the "new Book(...)" statement.

EDIT: The same is true for the Modules section

I already searched for this issue

Edition: 2nd Edition

Book Title: Get Started

Chapter: Chapter 2

Section Title: How We Organize in JS

Topic: Classes & Modules

getify commented 4 years ago

This difference is on purpose, to illustrate that a child class can define its own constructor with a different kind of signature from the parent constructor.