4 ms·
Arrow functions are worse, as far as I can tell the only benefit is to save a few characters of text. To get this win, now I have to always be conscious of how
by apalmer 11y ago
Arrow functions are worse, as far as I can tell the only benefit is to save a few characters of text. To get this win, now I have to always be conscious of how a function was created which syntax was used and as a result how 'this' was bound.
basically it is a 'fix' to a unusual but completely working and simple to reason about programming feature by adding a more correct but very inconsistent with the rest of the language that makes the whole thing harder to reason about.
does it serve any other benefit? I might be missing something as many people love this feature.
- steego 11y agoWhen I'm working with C#, I often write code like so: products .Where(p => p.Price >= range.low && p.Price <= range.high) .GroupBy(p => p.Category) .Select(g => new { Category = g.Key.Name, Count = g.Count() }) It's not just about saving a few characters. It's about about making certain types of libraries readable by reducing the amount of noise.
- nacs 11y ago> does it serve any other benefit Yes, as stated in the linked article: > arrow functions don't define this or arguments in their bodies, instead capturing these values from the environment Also: https://hacks.mozilla.org/2015/06/es6-in-depth-arrow-functions/ https://hacks.mozilla.org/2015/06/es6-in-depth-arrow-functio...