- array1, array2: one or more arrays are intended to be combined with the "array"
- ...array1, ...array2: the arrays must be merged.
The array.concat() method and the spread operator create a new array, but sometimes it is necessary not to create a new array, but to modify an existing array. You can use the array.push() method for this. The push() method adds the provided elements to the end of the existing array.
You can also add one or more elements to the beginning of an array using the array.unshift() method:
Since the array.push() method can take multiple elements, we can append the entire array using the spread operator when calling the push() method: