Nested Destructuring Patterns
Type deeply nested destructuring expressions.
Reaching Into Nested Data
Nested destructuring extracts values from objects within objects in a single statement. It is concise, but it interacts with types in ways worth understanding — and it can hurt readability if overused.
Destructuring a Nested Property
Mirror the object's shape on the left-hand side. To reach data.user.name, nest a pattern under user.
const data = { user: { name: "Ada", age: 36 } }
const { user: { name } } = data
console.log(name) // AdaAll lessons in this course
- Object Destructuring Types
- Array and Tuple Destructuring
- Default Values in Destructuring
- Nested Destructuring Patterns