Rest Parameters ( denoted by …argumentName ) can unwind an array or an object that allows you to quickly execute the value of an array/object.
const obj = {name: "a", age: 1}
const array = [1, 2, 3]
console.log(...array, 2); // 1 2 3 2
console.log({...obj, name: "Andrew"}); // {name: "Andrew", age: 1}
Also, it allows you to quickly accept multiple arguments in your function and get them as an array
function iTakeItAll(first, second, ...allOthers) {
console.log(allOthers);
}
iTakeItAll('foo', 'bar'); // []
iTakeItAll('foo', 'bar', 'bas', 'qux'); // ['bas','qux']