Hacker News new | ask | show | jobs
by JD557 1019 days ago
> JavaScript (and typescript) prefers them. Is it because of a convention or it really has advantages?

There are some slight differences: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

I believe the reason arrow functions are prefered in his is because of the way `this` is handled: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

2 comments

Ah! Thanks. I always forget the special "this" differences. I still prefer to use function when "this" is not involved though (I find strange to have a function as a variable, if you are not using it as a variable that is.)
you would be correct. :)