* they have a length
* their keys are typed, not limited to strings. Objects as keys actually works
* they can be cleared in a single call
* they can easily be iterated over keys, values or (key, value) pairs
* they have a length
* their keys are typed, not limited to strings. Objects as keys actually works
* they can be cleared in a single call
* they can easily be iterated over keys, values or (key, value) pairs
m = new Map([[new String(1), 1]])
> Map { "1": 1 }
m.get("1")
> undefinedThe fact that, up to ES5, there's been no agreement on which name to use for the equality function and no default implementation for it it's of no excuse to avoid the issue. It's their (the people who standardized it) Map type, and they should've been able to make it as useful as possible.
Can't do that for a hashmap since the value can change (by mutating the object) the hash would have to change as well and the object would have to move around. Not a sane proposition.
On top of that, the Map implementation could always call Object.freeze() on the keys that it receives
> forEach calls callbackfn once for each key/value pair present in the map object, in key insertion order.
https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ma...