DEV Community

Discussion on: Is "this" really that complicated in JavaScript?

Collapse
 
tilkinsc profile image
Cody Tilkins

Come from Lua, this isn't too confusing. However, it baffles me why they thought it was a good idea to change the this paradigm between arrow and normal function declaration. I've noticed even React will warn about the differences in docs.

Collapse
 
chuckchoiboi profile image
Chuck Choi

@tilkin Agree with you that the whole part isn't that confusing until you come across the arrow functions. It's just completely different from the typhttps://assets.grammarly.com/emoji/v1/1f642.svgical this keyword's pattern. But because of its lexical scoping, arrow functions are perfect to use for callback functions inside higher-order functions to inherit its parent scope. But at the same time, would've been easier to just utilize the explicit binding haha!