Object Destructuring and Spread
Extract object properties with destructuring, clone and merge objects with the spread operator, and use rest parameters in function signatures.
What Is Destructuring?
Destructuring extracts values from objects and arrays into named variables. It's shorthand for multiple property access statements — it makes code concise and clearly communicates which properties are used.
Object Destructuring Basics
Use curly braces on the left side of an assignment to extract named properties.
const user = { name: 'Alice', age: 30, role: 'admin' };
// Without destructuring:
const name = user.name;
const age = user.age;
// With destructuring:
const { name, age, role } = user;
console.log(name); // 'Alice'
console.log(age); // 30All lessons in this course
- Array Methods: map filter reduce find
- Object Destructuring and Spread
- Template Literals and Optional Chaining
- Modules: import and export