JavaScript Map & Set Quiz

Map and Set are JavaScript's built-in collections for key-value pairs and unique values. This quiz checks their basic methods, how keys and duplicates work, iteration order and the differences from plain objects.

Easy 10 questions ~5 minutes Pass at 80% Node.js 22

Choose a mode

Playing as a guest: sign in to keep your XP and streak.

Sample question

Question 1 of 10

What does this print?

const s = new Set([1, 2, 2, 3, 3, 3]);
console.log(s.size);
Show the answer

D. 3 A Set stores each value only once, so the duplicates are dropped and three values remain. Use size, not length.

What this quiz covers

  • Removing duplicates with Set
  • Map keys of any type vs object keys that become strings
  • size, get, set, has and iteration
  • Why objects in a Set are compared by reference
  • Turning a Map into JSON

Questions people ask

Do I need an account?

No. Anyone can play. Sign in to keep your XP, streak, badges and history.

Can I retake it?

Yes. Your best score is kept, and the questions and answers are shuffled each time.