Array

Array.prototype.concat

Merges two or more arrays into a new array without changing the existing arrays

Syntax

JavaScript
array.concat(...values)

Parameters

ParameterTypeDescription
valuesT | T[]Arrays and/or values to concatenate

Return Value

A new array containing the combined elements

Examples

Basic Usage
const a = [1, 2, 3];
const b = [4, 5, 6];
console.log(a.concat(b)); // [1, 2, 3, 4, 5, 6]
Practical Example
const arr = ['a', 'b'];
const result = arr.concat(['c'], ['d', 'e']);
console.log(result); // ['a', 'b', 'c', 'd', 'e']
Advanced Usage
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

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.