let array1 = [1, 2, 3]; let array2 = [4, 5, 6]; let combinedArray = array1.concat(array2); console.log(combinedArray);
In this code, we first define two arrays,
Next, we use the
concat() method to combine the two arrays into a single array, which we store in the
Finally, we log the value of the
combinedArray to the console.
This will output the following:
[1, 2, 3, 4, 5, 6]
Note that this creates a new array that contains the elements of both
array2, and does not modify either of the original arrays.