Using Spread Operators In Javascript

Using Spread Operators In Javascript

In this article, you will learn how to use spread operators in JavaScript.

The spread operator basically allows iterable operations such as an array or object to be expanded in other places.

Say we have two Arrays array1 and array2


 let array1 = ["Chelsea", "Arsenal", "WestHam"]; let array2 = ["Torino", "Juventus"]

We can use spread operators to merge the two arrays:


 let derbies = ["Everton", ...array1, "Liverpool", ...array2]

Aside merging the two arrays with the spread operator, we also added two properties between.