Javascript - Array concat() Method

The concat() method is used to combine two or more arrays together.

Description

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.

Syntax

array1.concat(array2, array3, ..., arrayX)

Parameter Values

ParameterRequire Description
array2, array3, ..., arrayX Required. The arrays to be joined

Return

An Array object, representing the joined array

Example

Join two arrays:

Demo

var h = ["XML", "Json"];
var s = ["OS", "SQL", "Linus"];
var c = h.concat(s);
console.log( c );//from w  ww. j  a  va 2 s  . com
//Join three arrays:
var k = ["ABC"];
var children = h.concat(s,k);
console.log( children);

Result