TRADEOFF BATTLE
Object vs Map for keyed JavaScript collections
A dashboard keeps adding, removing, counting, and iterating items by id. Would you store that data in a plain object or a Map?
The prompt
You are building a JavaScript dashboard that tracks selected rows by id. The UI needs to add and remove entries often, check whether an id already exists, show a count badge, iterate through the current selections, and clear the whole collection quickly. The ids are string values today, but the set behaves like a living collection rather than a fixed record shape. In the interview, the panel asks whether you would store this in a plain object or a Map.
Pick the direction you would defend
You are not looking for the universal winner. You are picking the strongest answer for this prompt.
Commit to a direction
Pick the option you would defend, then reveal the stronger interview framing for this prompt.