Rest
Array Rest
const add = (...valueList) => {
return valueList.reduce((total, value) => total + value, 0);
};
add(0, 1, 2, 3); // 6const add = (valueList) => {
return valueList.reduce((total, value) => total + value, 0);
};
add([1, 2, 3]); // 6Object Rest
const user = {
firstName: 'Foo',
lastName: 'BAR',
email: '[email protected]',
phoneNumber: '123'
};
const { firstName, lastName, ...remainingProperties } = user;
console.log(remainingProperties); // { email: '[email protected]', phoneNumber: '123' }
Last updated