JavaScript Default & Rest Parameters Quiz

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.

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?

function greet(name = "friend") {
  return `Hi, ${name}`;
}
console.log(greet());
Show the answer

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

What this quiz covers

  • 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

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.