« Bugzilla Issues Index
#2554 — indexOfIdentical uses reference comparison instead of equality comparison
- bug_id:
2554
- creation_ts:
2014-02-17 13:12:00 -0800
- short_desc:
indexOfIdentical uses reference comparison instead of equality comparison
- delta_ts:
2015-10-02 14:36:16 -0700
- product:
Harmony
- component:
proposals
- version:
Initial draft
- rep_platform:
All
- op_sys:
All
- bug_status:
RESOLVED
- resolution:
INVALID
- priority:
Normal
- bug_severity:
normal
- everconfirmed:
true
- reporter:
Marc Garcia
- assigned_to:
Allen Wirfs-Brock
- commentid:
7350
- comment_count:
0
- who:
Marc Garcia
- bug_when:
2014-02-17 13:12:12 -0800
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}));
- commentid:
7355
- comment_count:
1
- who:
Allen Wirfs-Brock
- bug_when:
2014-02-17 15:30:14 -0800
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.
- commentid:
14746
- comment_count:
2
- who:
Brian Terlson
- bug_when:
2015-10-02 14:36:16 -0700
Bulk closing all Harmony bugs. Proposals should be tracked on GitHub. The ES wiki is completely defunct at this point.