JS defines two arrays.
var arra=[1,2,3];
var arrb=[4,5,6];
To achieve [1,2,3,4,5,6], if direct arra.push (ARRB); Then ARRB will only act as an element of the ARRA. Perform
To merge or connect, you need to use the concat () method.
Concat (Array) method
The Concat () method is used to concatenate two or more arrays. The method does not alter the existing array, but only returns a copy of the concatenated array.
Array1.concat ([item1[, item2[, ... [, Itemn]]])
Description
The Concat method returns an Array object that contains the connection for array1 and any other items provided.
Items to add (item1 ... itemn) are added to the array in left-to-right order. If an item is an array, then add its contents to the end of the array1. If the item is not an array, it is added to the end of the array as a single array element.
The following is a copy of the element from the source array to the result array:
For the object parameters copied from the array being connected to the new array, the same object is still pointed to after replication. Any change in the new array and the source array will cause another change.
For numeric values or strings connected to a new array, only its value is copied. Changing the value in one array does not affect the value in the other array.
// concat () links two or more arrays together, but does not change existing arrays // Instead, it returns a new array after a link var a = [];a.concat ([4,5]); Console.log (a); // output here is [1, 2, 3] var a = [a.concat ([4,5]); Console.log (a); // output here is [1, 2, 3, 4, 5]
JS array merge (one array added to another array) method