Array.prototype.toObjectByProperty( element=>element.property )
naveen.chwl at gmail.com
Tue Aug 8 04:16:19 UTC 2017
On Tue, 8 Aug 2017 at 03:25 Jordan Harband <ljharb at gmail.com> wrote:
> Entries are an established pattern. Relitigating it isn't going to be
> useful. Something like this would only make sense if it accepted either an
> iterable of entries, or an array of entries (which is strictly less useful
> than taking an iterable) - no other input value would make sense to me.
They are established as a feature in the language. I am not trying to
relitigate that. I'm simply saying that when transitioning from a typical
iterable to an object we shouldn't be forced into it as an intermediary,
besides which that doesn't offer any advantage over the reduce mentioned
earlier in this thread, and even has worse performance. The [key, value]
pattern was originally introduced for Maps to allow objects as keys, which
isn't even valid in an object, besides the pattern not being a tight
structure in of itself.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss