Maps with object keys

Benjamin (Inglor) Gruenbaum inglor at
Mon Feb 17 13:09:12 PST 2014

I'm trying to work with ES6 Map objects and I ran into an interesting

I want to index/group based on several key values. Let's say my original
data is something like:


I want to group it based on the x and y property values, so I want the
result to look something like:

    {x:3,y:5} ==>  {x:3,y:5,z:3},{x:3,y:5,z:4}
    {x:3,y:4} ==>  {x:3,y:4,z:4},{x:3,y:4,z:7}
    {x:3,y:1} ==>  {x:3,y:1,z:1}

However, as the docs and draft say maps detect existence (
`Map.prototype.has ( key )`) for object the same way `===` works for
objects (specified in `SameValueZero(x, y)`).

I really don't see how to solve this other than implementing my own form of
hashing for these specific objects and 'rolling my own' logic here (instead
of working directly with `Map`s).

For comparison - in Python for example I'd use a dictionary with tuple keys.

So I'm wondering, what's the point of being able to use object keys in
`Map` objects if the equality check performed is reference equality?

I feel like I'm either missing something obvious here or we have a
usability issue on our hands.


(Also asked in SO )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list