Predict Object Destructuring
Predict Output Easy
Question
What does this code print?
Code
const { name: firstName, age } = { name: "Ada", age: 36 };
console.log(firstName, age);
Hint
Destructuring with renaming: name is extracted into firstName.
Explanation
Object destructuring with renaming: { name: firstName } extracts the name property and assigns it to a variable called firstName. { age } uses shorthand — extracts age into a variable also called age. So firstName is "Ada" and age is 36, printed as: Ada 36
Related Resources
Related Lessons
- JavaScript Objects
Learn about object destructuring.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.