What is going on in this code?
var a = {a:1}; var b = {b:2}; var c = {}; c[a] = 1; c[b] === 1 // true! c[b] = 2; c[a] === 2 // true!
Spec
Why you use an object as a key, the key is becoming the object.toString() 's result which is [Object Object],
object.toString()
[Object Object]
So what you are dothing is set a value to the property "[Object Object]", and get the value by the property "[Object Object]".
"[Object Object]"