3 ms·
It sounds like people will prefer the (a,b) => {} syntax over function (a,b) {} simply because it's more concise and looks better, not because of its usefulness
by cormacrelf 15y ago
It sounds like people will prefer the (a,b) => {} syntax over function (a,b) {} simply because it's more concise and looks better, not because of its usefulness.
- darklajid 15y agoSometimes concise is (arguably, of course) better. Whenever I pass a simple and short function, for example as a predicate to grep/filter or as a tiny implementation for map/reduce I feel that "function" is half of what I type - and distracting. Worse, explicitly "return"ing adds more noise. Most of my anonymous functions are really, really small. If they are usually on the level of "d % 2 == 0" or "d.slice(42)" then removing the overhead of "function (d) { return" seems a good idea. Not a huge deal, but nice nevertheless.