JavaScript Array.prototype.concat() Method
The concat() method joins arrays and values into a new array, leaving the originals unchanged.
Description
The concat() method merges the array with other arrays or values and returns the result as a new array. The original arrays aren't changed. Array arguments are spread one level deep, while nested arrays inside them are kept as they are.
The spread syntax, [...a, ...b], does the same job and is often easier to read. Note that the copy is shallow: objects inside the arrays are shared, not cloned.
Because it returns a new array, concat() is handy where data mustn't be mutated, such as state in UI frameworks. Objects that aren't arrays are added as a single element, even array-like ones such as a NodeList; convert those with Array.from() first if you want their items.
Syntax
array.concat(value1, value2, ...)Parameters
- value1, value2, ...Arrays or values to add to the end. Arrays are flattened one level; other values are added as they are.
Return Value
A new array containing the elements of the original followed by the new values.
Example
Browser Support
The following information will show you the current browser support for the Array.prototype.concat() method. Hover over a browser icon to see the version that first introduced support for this method.
Desktop





Tablets & Mobile





