Quiz di JavaScript: Default & Rest Parameters

This JavaScript quiz covers default parameter values and rest parameters (...args). You will predict when a default is used, what a rest parameter holds and how it differs from the old arguments object and from spread.

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?

function greet(name = "friend") {
  return `Hi, ${name}`;
}
console.log(greet());
Mostra la risposta

C. Hi, friend No argument was passed, so name would be undefined and the default "friend" is used instead.

Cosa copre questo quiz

  • Default values like function greet(name = "friend")
  • A default is used for undefined, not for null or 0
  • Rest parameters collect extra arguments into a real array
  • Rest vs the arguments object, and rest vs spread
  • Defaults are evaluated on every call

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.