Do you know what will be the output of this code?
JavaScript
const a = {};
const b = { key: "b" };
const c = { key: "c" };
a[b] = 123;
a[c] = 456;
console.log(a[b]);
Show answer and explanation
The answer is 456.
Both b and c become the string "[object Object]" when used as keys. The second assignment overwrites the first. Use a Map for object keys.