Back to feed
Dev.to
Dev.to
5/10/2026
Spread vs Rest Operators in JavaScript

Spread vs Rest Operators in JavaScript

Short summary

Spread operators (...) expand collections into individual elements for use in function calls, array literals, and object merging, while rest operators gather multiple individual elements into a single array or object during function parameters and destructuring. Though identical in syntax, they serve opposite purposes—spread unpacks values, rest collects them. A comprehensive tutorial with practical examples.

  • Spread unpacks: [...array] or ...array expands items individually
  • Rest collects: ...args gathers multiple values into one array
  • Context determines function—same syntax, opposite effects

Generated with AI, which can make mistakes.

Is this a good recommendation for you?

Explore more