REST AND SPREAD OPERATORS FOR OBJECT LITERALS
In the ECMAScript 2018 specification, all the elegance of rest and spread operators in arrays is now also available inside object literals. This allows you to merge objects or collect properties into new objects.
Rest Operator
The rest operator allows you to use a single rest operator when destructuring an object to collect all remaining unspecified enumerable properties into a single object. This can be done as follows:
const person = { name: 'Matt', age: 27, job: 'Engineer' };
const { name, …remainingData } = person;
console.log(name); // Matt
console.log(remainingData); // { age: 27, job: 'Engineer' }
The rest operator can be used at most once per object literal and must be listed last. Because there can be only a single rest operator per object literal, it is possible to nest the rest operators. When nesting, because there is no ambiguity about which elements of the property subtree are allocated...