javascript
javascript
Spread & Rest Operators in Javascript
Live
bolt
Level1
Progress0%

Spread & Rest Operators in Javascript

CARD 1

Introduction

Login to report note issues for this section.

Spread & Rest Operators

Both the spread and rest operators use the same syntax — three dots (...) — but they do opposite things depending on where they are used.

OperatorWhere usedWhat it does
Spread (...)Where values are expectedExpands an iterable into individual elements
Rest (...)Where parameters are definedCollects multiple elements into a single array

A simple way to remember:

  • Spread — takes one thing and spreads it into many.
  • Rest — takes many things and collects them into one.