JavaScript Rest and Spread

Learn about rest parameters and spread syntax in this lesson.

By the end of this lesson, we’ll be able to do the following:

  • Use rest parameters to collect an arbitrary number of property keys in an object into a new object.
  • Apply the spread operator to create a shallow copy of an object.

Rest parameters and spread syntax with ...

Depending on the context, the syntax ... can be used as rest parameters or spread syntax. We can use rest and spread with arrays or objects.

Rest parameters

The rest parameters can collect an arbitrary number of property keys in an object into a new object:

Get hands-on with 1200+ tech skills courses.