← 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);
- A.Meena undefined
- B.undefined Unknown
- C.Meena Unknown
- 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 →