Array/Object Destructuring Basics
Array and object destructuring: basics, skipping items, defaults, renaming, and a simple swap trick.
Intro
Goal: Pull values out of arrays/objects cleanly.
- Array destructuring
- Skipping and defaults
- Object destructuring
- Renaming and swap trick

Array basics
Array patterns match positions. The first element goes to the first variable, and so on.
// Array destructuring: assign by position
const pair = [10, 20];
const [x, y] = pair;
console.log("x:", x);
console.log("y:", y);

All lessons in this course
- Array/Object Destructuring Basics
- Rest & Spread — Idiomatic Arrays and Objects