4 ms·
And here I thought scope was kind of disaster in JS: - `const fooFunc = () => {}` is treated differently than `function fooFunc() {}` in declaration and subseq
by dclowd9901 5y ago
And here I thought scope was kind of disaster in JS:
- `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.
- austincheney 5y agoThe this context changes, but I recommend developers not use this. That isn’t a scope issue though.
- mweberxyz 5y agoThere 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?