How to use push() Method In Javascript
We create the N arrays and then concatenate the array by using the push() method. In this, we also use the spread operator(…) which iterates over each of the values.
const arr1 = [11, 12, 13];
const arr2 = [14, 15, 16];
arr1.push(...arr2);
console.log(arr1);
Output
[ 11, 12, 13, 14, 15, 16 ]
What is the most efficient way to concatenate N arrays in JavaScript ?
In this article, we will see how to concatenate N arrays in JavaScript. The efficient way to concatenate N arrays can depend on the number of arrays and the size of arrays.
To concatenate N arrays, we use the following methods:
Table of Content
- Using push() Method
- Using concat() Method
- Using Spread Operator
- Using Array.from with Mapping Function: