What is spread and rest operator?

Updated May 6, 2026

Short answer

Spread expands, rest collects values.

Deep explanation

Spread copies arrays/objects, rest gathers function args.

Real-world example

Cloning state in React.

Common mistakes

  • Confusing rest with spread.

Follow-up questions

  • Can objects use spread?
  • Are they shallow copies?

More JavaScript interview questions

View all →