Map and Set Collections
A plain object is useful for a fixed profile. Use a Map when the important operation is looking up a value by a key, and use a Set when each value should appear only once.
javascript
const badgeByRole = new Map([
["host", "gold"],
["producer", "silver"]
]);
const citiesOnTour = new Set(["Seoul", "Lisbon", "Seoul"]);
console.log(badgeByRole.get("producer"));
console.log(citiesOnTour.size);
Checkpoint
The Map stores explicit key-value entries. The Set kept only two cities even though "Seoul" appeared twice. The next lesson uses these collections for a different task: a playlist lookup and artist roster.
Learn more
MDN's references for Map and Set explain their methods and iteration behavior.