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

Prepare · Practice · Crack

What's the difference between spread and rest?

Quick answer

Same `...` syntax: spread expands an iterable into elements; rest collects remaining items into an array.

In detail

Spread is used where values are expected — copying/merging arrays and objects, passing args. Rest is used where a binding collects the leftovers — function parameters and destructuring. Position tells you which one it is.

const merged = [...a, ...b];        // spread
const clone = { ...obj };           // spread
function sum(...nums) {}            // rest
const [head, ...tail] = list;       // rest

Why interviewers ask this: Tests understanding of one operator's two roles.

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 →