Learn JavaScript
Object Destructuring
35.4
Lesson

The Rest Pattern

If the number of properties in the object is more than the number of variables, the extra elements are omitted.

In the example given below, the object has three properties, but we have only two variables to store them. The third property is omitted.

If we want to include the rest of the properties in a variabale we can use the rest pattern. The rest pattern has three dots ... as the pre-fix.

In the example given below, we are using one variable to store the first property. The second and the third properties are stored in the ...rest variable.