WBF Academy
Functional Beginner 2 min read

Spread vs Rest Operators

Same syntax, opposite purposes

JS Academy

JS Academy

JavaScript Engineer

1 month ago

The spread operator (`...`) expands an iterable — like an array or object — into individual elements or properties. The rest operator uses the same `...` syntax but does the opposite: it collects multiple elements into a single array. Spread is used in function calls, array literals, and object literals; rest is used in function parameter lists and destructuring patterns. Understanding which role the `...` plays depends entirely on context.

#javascript #spread #rest #es6