snipplets.dev/snipplets/code/JavaScript/spread.js
2023-08-05 22:45:06 +03:00

12 lines
189 B
JavaScript

function sum(x, y, z) {
return x + y + z;
}
const numbers = [1, 2, 3];
console.log(sum(...numbers));
// expected output: 6
console.log(sum.apply(null, numbers));
// expected output: 6