456 is output,
— Object keys are automatically converted into strings. We are trying to set an object as a key to object a, with the value of 123.
— However, when we stringify an object, it becomes "[object Object]".
1/3
— Object keys are automatically converted into strings. We are trying to set an object as a key to object a, with the value of 123.
— However, when we stringify an object, it becomes "[object Object]".
1/3
— So what we are saying here, is that a["[object Object]"] = 123. Then, we can try to do the same again. c is another object that we are implicitly stringifying. So then, a["[object Object]"] = 456.
2/3
2/3
Then, we log a[b], which is actually a["[object Object]"]. We just set that to 456, so it returns 456.
3/3
3/3
Loading suggestions...