Re:Modern Javascript: Everything you missed over the last 10...
by austincheney on Saturday May 15, 2021 @03:23PM
(#27168087)
The this context changes, but I recommend developers not use this. That isn’t a scope issue though.
Re:Modern Javascript: Everything you missed over the last 10...
by mweberxyz on Saturday May 15, 2021 @03:30PM
(#27168145)
There would be no point in having two ways to do the exact same thing if function-style declaration and arrow-style declaration implementations were identical. Why would they add a new feature to the language if it was purely syntactic sugar?
- `const fooFunc = () => {}` is treated differently than `function fooFunc() {}` in declaration and subsequent access.
- A function's invocation context changes depending on how it was declared (fat arrow vs. function declaration)
Don't get me wrong: I love JS, but this is not one of the things I felt made it intuitive.