🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: Functions, Arrays and Objects: all 10 questions

Quiz: Functions, Arrays and Objects · Question 10 of 10

What does this print? (code)

What does this print?

const { name, city = "Unknown" } = { name: "Meena" };
console.log(name, city);
  1. A.Meena undefined
  2. B.undefined Unknown
  3. C.Meena Unknown
  4. D.It throws an error
Answer & explanation

Correct answer: Meena Unknown

Destructuring can give a default value when the property is missing.

Can you get the rest right without peeking?

Take the timed Quiz: Functions, Arrays and Objects quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →