-
Notifications
You must be signed in to change notification settings - Fork 247
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
I think arrow functions create closures #73
Comments
They do create their own scope - arrow functions simply don’t create a binding for this/super/arguments, unlike all other functions, so they bubble up lexically. |
Then maybe this: Should say this: (Still learning the terminology. That's the main reason I picked up this book) |
Could you create a PR to fix this? 🙇 |
Will do, tomorrow :) |
Opened PR #75 |
Fixed in #75 |
The section Lexical Scoping https://ponyfoo.com/books/practical-modern-javascript/chapters/2#lexical-scoping-8zsxfqh9
claims that arrow functions don't create closures. It looks like they do. In fact, the code relies on closure of arguments in the evaluation of the returned function. I think this should say "arrow functions don't create their own lexical scope, so arguments is accessed from the closure of the enclosing function".
calc=((a)=>( (b)=>{debugger; return a+b} ))(a=1); calc(2)
The text was updated successfully, but these errors were encountered: