Array.prototype.concat
Merges two or more arrays into a new array without changing the existing arrays
Syntax
array.concat(...values)Parameters
| Parameter | Type | Description |
|---|---|---|
| values | T | T[] | Arrays and/or values to concatenate |
Return Value
A new array containing the combined elements
Examples
const a = [1, 2, 3];
const b = [4, 5, 6];
console.log(a.concat(b)); // [1, 2, 3, 4, 5, 6]const arr = ['a', 'b'];
const result = arr.concat(['c'], ['d', 'e']);
console.log(result); // ['a', 'b', 'c', 'd', 'e']const nums = [1, 2];
console.log(nums.concat(3, [4, 5])); // [1, 2, 3, 4, 5]Understanding Array.prototype.concat
The Array.prototype.concat method in JavaScript merges two or more arrays into a new array without changing the existing arrays. It belongs to the Array object and is one of the most widely used methods for working with array values in modern JavaScript and TypeScript applications.
The method signature is array.concat(...values). It accepts 1 parameter: values. When called, it returns a new array containing the combined elements. Understanding when and how to use concat() helps you write more expressive, readable code.
Common use cases for Array.prototype.concat include data transformation, input validation, API response processing, and building reusable utility functions. It works well alongside related methods like array-flat, array-push, array-splice, enabling you to chain operations together for complex data manipulation pipelines.
Browser support for Array.prototype.concat is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. It is also fully supported in Node.js and Deno. For older environments, transpilation with Babel or a polyfill may be needed.
Browser Compatibility
Supported in all modern browsers (Chrome, Firefox, Safari, Edge) and Node.js. Part of the ECMAScript standard.
Related Methods
Array.prototype.flatCreates a new array with all sub-array elements concatenated into it recursively up to the specified depth
Array.prototype.pushAdds the specified elements to the end of an array and returns the new length of the array
Array.prototype.spliceChanges the contents of an array by removing or replacing existing elements and/or adding new elements in place
String.prototype.concatConcatenates the string arguments to the calling string and returns a new string
More Array Methods
Other methods in the Array object
Related Tools
More Array Methods
Explore JavaScript Methods
Browse our complete reference of 410 JavaScript methods with syntax, examples, and explanations.