JavaScript Array concat() method
merge two or more arrays

concat() method concatenates (joins) two or more arrays.

syntax

concat(value1, value2, /* …, */ valueN)

value1, …, valueN Arrays and/or values to concatenate into a new array.

If all valueN parameters are omitted, concat() returns a shallow copy of the existing array on which it is called.

concat() method returns a new array, containing the joined arrays.

concat() method does not change the existing arrays.

myArray.concat() returns a shallow copy of the existing array.

myArray1.concat(myArray2, myArray3) is the same as ↴

[...myArray1, ...myArray2, ...myArray3]

concat() method preserves empty slots if any of the source arrays is sparse.

const myArray1 = ['a',, 'b'];

const myArray2 = ['c',, 'd'];

myArray1.concat(myArray2); returns ↴

['a', empty, 'b', 'c', empty, 'd']

syntax description
merge two or more arrays and return a new array
myArray1.concat(myArray2, myArray3, ..., myArrayN)