Using Spread Operators In Javascript
Posted on: March 02, 2021 by Prince Chukwudire
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.
Share on social media
//