Understanding the Spread Operator in Function Calls in Javascript


Use the spread operator to pass arrays as arguments to functions.

Source Code

function sum(x, y, z) {
  return x + y + z;
}
const numbers = [1, 2, 3];
console.log(sum(...numbers));
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments