๐Ÿ“ค JavaScript

Destructuring Patterns You'll Use Every Day

๐Ÿ“… Jul 4, 2026 โฑ 3 min read

Destructuring unpacks values in one line. Modern codebases use it in every file โ€” these are the patterns worth internalizing.

The everyday set

const student = { name: "Priya", dept: "CSE", marks: { cn: 88 } };

const { name, dept } = student;               // basics
const { name: fullName } = student;           // rename
const { hostel = "Day scholar" } = student;   // default
const { marks: { cn } } = student;            // nested

const [first, second] = [1, 2, 3];
const [head, ...rest] = [1, 2, 3];            // rest
[a, b] = [b, a];                              // swap without temp!

// function parameters โ€” the biggest win
function Card({ title, image, tags = [] }) { ... }
// vs function Card(props) { props.title... }

// loops
for (const [key, value] of Object.entries(obj)) { ... }
const [, second] = arr;                       // skip with commas

Where it bites

React hooks are array destructuring: const [count, setCount] = useState(0). Full lesson: Destructuring.

โ† All Articles