0 votes
in JavaScript by
What is a spread operator in Javascript?

1 Answer

0 votes
by

Spread operator allows iterables( arrays / objects / strings ) to be expanded into single arguments/elements. Let's take an example to see this behavior,

function calculateSum(x, y, z) {
  return x + y + z;
}

const numbers = [1, 2, 3];

console.log(calculateSum(...numbers)); // 6

Related questions

0 votes
asked Sep 29, 2023 in JavaScript by JackTerrance
0 votes
asked Oct 26, 2023 in JavaScript by DavidAnderson
...