Rest Parameters
JS · Variables & Constantsfunction fn(...args) {}function sum(...numbers) {
return numbers.reduce((total, n) => total + n, 0);
}
console.log(sum(5, 10, 15));30Note Rest must be the last parameter. Unlike the old arguments object, rest gives you a real Array with all array methods.