var a={},
b={key:'b'};
a[b]=123;
In this case, b as key is "[object Object]" - result of b.toString()
Therefore, every keys are same as "[object Object]" whenever Object passed into Array Key
In this case, we can solve this problem using ECMAScript 6 Maps
var a = new Map(),
b = {key: 'b'};
a.set(b, 123);
Top comments (0)