← JavaScript Foundations
8 / 26
Lesson 8 — Destructuring
Unpack values
Destructuring pulls values out of objects or arrays into variables in one step. With objects, the names inside the braces must match property names; with arrays, values are taken by position. You can list as many names as you need, separated by commas.
const point = { x: 3, y: 7 };
const { x, y } = point;
console.log(x + y); // 10
Why it matters: React props, API responses and function options are all read this way.
Want it another way?
Task
Destructure both name and age from the object and log them on separate lines.
Run your code — when the output matches the task, you will see a green check. Then mark the lesson complete.
Test your knowledge
A quick 3-question quiz on this lesson — instant feedback.