The concat() method is used to combine two or more arrays together.
The concat() method is used to combine two or more arrays together.
It does not change the existing arrays, but returns a new array, containing the values of the joined arrays.
array1.concat(array2, array3, ..., arrayX)
Parameter | Require | Description |
---|---|---|
array2, array3, ..., arrayX | Required. | The arrays to be joined |
An Array object, representing the joined array
Join two arrays:
var h = ["XML", "Json"]; var s = ["OS", "SQL", "Linus"]; var c = h.concat(s); console.log( c );//from w ww.ja va 2 s. c om //Join three arrays: var k = ["ABC"]; var children = h.concat(s,k); console.log( children);