Destructuring — Free JavaScript Tutorial
Learn Destructuring in JavaScript with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.
TL;DR: Learn Destructuring in JavaScript with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.
Written & reviewed by the Syllab.in Academic Team (CBSE/NCERT subject experts) · Updated
Destructuring in JavaScript
Array destructuring: `const [a, b, c] = [1, 2, 3]`. Skip elements: `const [, second] = arr`. Default values: `const [a=0] = []`.
Object destructuring: `const { name, age } = user`. Rename: `const { name: fullName } = user`. Default: `const { score=0 } = user`.
Nested destructuring: `const { address: { city } } = user`.
Function parameter destructuring: `function greet({ name, age })` — pass an object, extract properties directly.
Swap variables: `[a, b] = [b, a]` — no temp variable needed!
Learn Destructuring step by step with Syllab's free interactive JavaScript tutorial — runnable code examples, practice exercises and instant AI feedback, all free with no signup. Explore the full JavaScript course →