How it works...

The way I think about the rest operator is to think of it spreading members of the collection out into the current collection. In the preceding recipe, this means that the members of usRockets and chineseRockets are spread out into the new array, rockets.

This spreading means that they can be referenced in the same syntactic level as the standalone sovietRocket when creating the new array. This combining of elements into a new structure is sometimes referred to as structuring, mirroring the destructuring terminology.

Get ECMAScript Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.