JavaScript · Junior · Question 60 of 75
What are title and year after this destructuring?
const movie = { name: "Up" };
const { name: title, year = 2009 } = movie;- ✓Correct answer:
titleis"Up",yearis2009 - 2
nameis"Up",titleis undefined - 3It throws because
yeardoesn't exist
Explanation
name: title renames the variable, and = 2009 provides a default when the property is undefined.