Problem Statement
Why might Map be preferred over plain Object for key–value storage?
Explanation
Map is designed for key–value collections with arbitrary key types and predictable iteration order.
Objects are best for structured data and use string/symbol keys; they also inherit from Object.prototype unless created with null prototype.
Code Solution
SolutionRead Only
const m = new Map();
const k = { id: 1 };
m.set(k, 'value');
console.log(m.get(k)); // 'value'
console.log([...m]);