archives

« Bugzilla Issues Index

#2554 — indexOfIdentical uses reference comparison instead of equality comparison


when using object as a key, if the key is not the same instance of object, map doesn't found related enty, there is a need for exact object, would be better to have equality comparison

// it works
var map = new Map();
var k = {'x':5};
map.set(k,'foo');
console.log(map.get(k));

// it does not work
var map = new Map();
map.set({'x':5},'foo');
console.log(map.get({'x':5}));


This is by design and won't change for ES6.

It's possible that in the future the Map constructor might be extended to accept an optional comparisons function. This would require someone developing a more comprehensive proposal for such an extension.


Bulk closing all Harmony bugs. Proposals should be tracked on GitHub. The ES wiki is completely defunct at this point.