puzzle 10 · javascript
What does this log?
const o = {};
o[1] = "a";
o["1"] = "b";
console.log(Object.keys(o).length);1
2
0
TypeError
why
Plain object keys are always strings, so o[1] and o["1"] are the same key — the second write just overwrites the first. A Map keeps 1 and "1" distinct.