Darien Valentine (2017-08-08T05:31:49.000Z)
valentinium at gmail.com (2017-08-08T05:38:16.394Z)
> forced into it as an intermediary Fortunately, no force is involved :) T.J. Crowder indicated an intention to draft a proposal that I believe aligns with your ideas for converting objects to a single object by key with an all-in-one map+compose method. It is not necessary for there to be only a single proposal in this space — aside from the fact that having diversity of ideas on the table is healthy, the two ideas do not seem to be in conflict with each other. > has worse performance It’s a bit hard to speak about the performance of methods no engine has implemented, but you might be overestimating the cost of `Array.prototype.map`. > The [key, value] pattern was originally introduced for Maps to allow objects > as keys [...] You described earlier a previous unfamiliarity with the various `entries` methods on collections. This might have contributed to an impression that entries are a concern of Map specifically. While Map introduced entries, in real-world code, I think it’s safe to say confidently that the frequency of use of `Object.entries` for iteration (as illustrated in Logan Smyth’s earlier comment) and transformative operations (as mentioned in Jussi Kalliokoski’s comment) dwarfs that of its use for map initialization. > Yes unfortunately this doesn't apply to forEach, [...] Are you referring to destructuring? It does: const obj = { apples: 2, bananas: 17, blueberries: 9 }; const numberOfFruitsThatStartWithB = Object .entries(obj) .filter(([ key ]) => key.startsWith('b')) .reduce((acc, [ , value ]) => acc + value, 0);