JavaScript rest operator

This is the final post in our JavaScript series on destructuring. Let’s focus on the rest operator, which materializes with three little dots ... as follows:

One way to put it is that the rest operator means “everything else goes into a new array.”

This syntax also works with objects, with the “rest of the properties going into a new object”:

The rest operator can also be used in a function to catch several parameters in an array:

Alain Chautard

Alain is a Google Developer Expert in Web Technologies, Angular, and Google Maps. His daily mission is to help development teams adopt Angular and build at scale with the framework. He has taught Angular on all six continents! A world traveler and photographer, Alain is also an international conference speaker, and a published author of several video courses.