ForgeFrontend — Prepare, Practice, Crack
Secure checkout
Lifetime access
Instant Drive delivery
Free updates forever

Prepare · Practice · Crack

What is destructuring? Show array and object examples.

Quick answer

Syntax to unpack values from arrays/objects into variables, with defaults, renaming and rest.

In detail

Destructuring pulls values out concisely. Arrays unpack by position (with skipping and defaults); objects unpack by key (with renaming, defaults and a rest collector). It's everywhere in function params and React.

const [first, , third = 0] = [10, 20];
const { name: n = "?", ...rest } = { name: "Kit", price: 499 };
let x = 1, y = 2; [x, y] = [y, x]; // swap

Why interviewers ask this: Baseline modern-syntax fluency.

This is 1 of 118+ questions in the JavaScript Interview Kit

Get every question with detailed answers, follow-ups and real code — plus coding challenges and a last-minute revision sheet. One-time payment, instant access.

⚡ Get the JavaScript Interview Kit → ₹299

Full kit

JavaScript Interview Kit · ₹299

Get it →