DEV Community

Discussion on: Suggestions for using `...arguments` while working with functions in javascript.

Collapse
 
aralroca profile image
Aral Roca

Is useful, for example, if doesn't matter how many parameters receive the function:

const sum = (...numbers) => numbers.reduce((a, b) => a + b, 0);

sum(1, 4); // 5
sum(2, 3, 4); // 9