Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ch. 6 – Why use parentheses in the class shorthand example? #362

Closed
mikegowen opened this issue Feb 23, 2018 · 2 comments
Closed

Ch. 6 – Why use parentheses in the class shorthand example? #362

mikegowen opened this issue Feb 23, 2018 · 2 comments

Comments

@mikegowen
Copy link

mikegowen commented Feb 23, 2018

http://eloquentjavascript.net/3rd_edition/06_object.html#c_JKY9zuey2L

let object = (new class { getWord() { return "hello"; } });
console.log(object.getWord());
// → hello

If I'm not mistaken, the outer parentheses aren't necessary here. If they are, maybe call attention to them. If they aren't necessary, it would seem better to leave them off as this expression would then more obviously map to how you'd write a function expression (a comparison you already make alongside the code).

P.S. Chapter 6 is pretty tough. I was warned of this chapter before I started the book, and it didn't disappoint :) I was going to submit a big issue with a few reasons why it's difficult and how it could be addressed, but I'll try to address them in individual issues.

marijnh added a commit that referenced this issue Feb 23, 2018
@marijnh
Copy link
Owner

marijnh commented Feb 23, 2018

You are right, those can be removed. See attached patch.

I was warned of this chapter before I started the book,

It was worse in the 2nd edition ;)

@marijnh marijnh closed this as completed Feb 23, 2018
@mikegowen
Copy link
Author

I agree, I've been through about 3/4 of the 2nd edition. Started over when the 3rd came out and it has definitely been smoother. Kudos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants