Let’s say, we have two arrays:
let arr1 = [1, 2, 3] let arr2 = [5, 6, 7]
Now, you want to have a third array that merges the two arrays:
let arr3 = [1, 2, 3, 4, 5, 6]
To achieve that, you can simply destructure the two arrays and use the result to create another array like following:
let arr3 = [...arr1, ...arr2] console.log(arr3) [1, 2, 3, 4, 5, 6]