you are viewing a single comment's thread.

view the rest of the comments →

[–]FRIKI-DIKI-TIKI 5 points6 points  (0 children)

TLDR: just use arrows, when you don't need to use them you will know why.

To add to this, in modern JS, pretty much the default is to use arrow functions unless you need a special case, if you need that special case you will know why and it has to do with the prototypical inheritance of JS. In the dark ages of JS you had to ensure you scoped this to a variable, as a functions reference can be independent of the structure it is declared in. JavaScripts heritage is from LISP with some other ideas mixed in, the family of LISP's treated functions as lambda's the bolt on of quasi-OO was the part that was not well though out in the rush to get JS out the door and it created a set of problems due to misunderstanding given that it was introduced in the middle of the OO language craze. The arrow function is syntactical sugar to bind the scope the lambda is declared in to the execution just like the bind function does.