snipplets.dev/code/JavaScript/spread.js

12 lines
189 B
JavaScript
Raw Normal View History

2021-11-19 04:02:42 +03:00
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