Array.prototype.concat()

Merges two or more arrays into a new array.

Since ES1 Spec ↗

Syntax

arr.concat(...values)

Parameters

NameTypeRequiredDescription
values any No Arrays or values to concatenate. Arrays are flattened one level; non-array values are appended as-is.

Returns

Array — A new array consisting of the elements of the source and the arguments.

Examples

console.log([1, 2].concat([3, 4], 5));
Output
[ 1, 2, 3, 4, 5 ]
console.log([1].concat([[2]]));
Output
[ 1, [ 2 ] ]

Notes

Does not mutate any of the source arrays. Only flattens one level; nested arrays stay nested. The spread operator `[...a, ...b]` is a common alternative.

Browser & runtime support

EnvironmentSince version
chrome 1.0
firefox 1.0
safari 1.0
edge 12
node 0.10

See also