4 ms·
> JavaScript (and typescript) prefers them. Is it because of a convention or it really has advantages? There are some slight differences: https://developer.moz
by JD557 3y 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/Reference/Functions/Arrow_functions 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/Reference/Operators/this https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
- weatherlight 3y agoyou would be correct. :)
- TrianguloY 3y agoAh! 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.)