JavaScript – Concatenate Array

To concatenate an array to another array in JavaScript, call concat() method on first array and pass the second array as argument to the concat() method.

concat() method returns a new array with elements of the second array concatenated to the elements of first array.

concat() method does not modify the original arrays.

Example

In the following example, we have taken two arrays in arr1 and arr2. We concatenate elements of arr2 to arr1 using concat() method.

index.html

ADVERTISEMENT

Conclusion

In this JavaScript Tutorial, we learned how to concatenate an array to another array using concat() method.