Array.prototype.toObjectByProperty( element=> )

T.J. Crowder tj.crowder at
Fri Aug 11 06:17:36 UTC 2017

On Thu, Aug 10, 2017 at 11:24 PM, Alexander Jones <alex at> wrote:
> As far as I'm concerned, "most data arrays" — at least the ones
> you're speaking about — should actually be `Map`s.

I see the point you're trying to make, but

1. I routinely want paging and other access by arbitrary index

2. I routinely want to change the order, which is expensive with Maps

3. I'm usually receiving these by deserializing JSON

Granted #3 could be solved by making the JSON even more verbose than it is
(`[["foo", {"id":"foo",..}],["bar",{"id": "bar", ...],...]`) and then
creating the Map from that temporary array of arays :-) Not least
because of the knock-on effects on the generating code. So I'd need a way
to create the Map from the array even if I *were* using Maps from then on
(such as my `Map.from`).

Arrays are great random-access, sortable, tranferrable format; and
highly-optimized on modern JavaScript engines. No need to change it. And if
I *did* change it, I'd still need a way to create the Map in the first
place from the obvious transfer format: An array.

-- T.J. Crowder
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list