Functional
Beginner 2 min read
Spread vs Rest Operators
Same syntax, opposite purposes
JS Academy
JavaScript Engineer
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