Quiz di JavaScript: Map & Set

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.

Facile 10 domande ~5 minuti Superato con il 80% Node.js 22

Scegli una modalità

Stai giocando come ospite: accedi per salvare XP e serie.

Domanda di esempio

Domanda 1 di 10

What does this print?

const s = new Set([1, 2, 2, 3, 3, 3]);
console.log(s.size);
Mostra la risposta

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

Cosa copre questo quiz

  • 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

Domande frequenti

Serve un account?

No. Chiunque può giocare. Accedi per salvare XP, serie, badge e cronologia.

Posso rifarlo?

Sì. Il tuo miglior punteggio resta salvato, e domande e risposte vengono mescolate ogni volta.