Spread Operator

Describing the spread Operation

  • The spread operator is represented using ... the syntax
  • It allows an iterable to be expanded as arguments
  • This iterable can be an array, string, etc.
  • This operator is useful in function calls

Defining an Array

let fruits = ['Apple', 'Banana'];
console.log(fruits.length);
// 2

Defining a Custom Function

function combine(x, y) {
    return x + y;
}

Using the spread Operation

console.log(combine(...fruits));
// "AppleBanana"
Next

Destructuring Assignment