3 ms·
Spread (for arrays) was added with ES6. This just adds that kind of thing for objects (ES2017). let a = [1, 2, 3]; Math.max(...a); // 3 If you use that op
by tomatsu 10y ago
Spread (for arrays) was added with ES6. This just adds that kind of thing for objects (ES2017).
let a = [1, 2, 3];
Math.max(...a); // 3
If you use that operator in parameters, it's rest (i.e. variadic stuff).
function sum(...numbers) {
return numbers.reduce((a, b) => a + b, 0);
}
sum(1, 2, 3, 4, 5); // 15