CKTIS / JavaScript
Array.prototype.concat: shallow non-mutating concatenation
concat creates a new array from its receiver and arguments, spreading arrays by one level without changing the sources.
Version: ECMAScript 2026 draft; example target: Node.js 24.22.2
Syntax
array.concat(...values)array.concat(...values) creates a new array. The receiver is copied first, followed by the arguments: arrays and objects whose Symbol.isConcatSpreadable is true are spread one level; other values become single elements. Nested objects keep the same references.
The method does not mutate its sources, although the result can use the array species constructor. Sparse holes are preserved rather than converted to undefined. Excessive result length and errors from getters or proxies propagate. The example confirms shallow concatenation and an unchanged input length.
Examples
const nested = {value: 1};
const source = ["A", nested];
const result = source.concat(["B"], [["C"]]);
console.log(result.map(value => Array.isArray(value) ? `[${value}]` : typeof value === "object" ? value.value : value).join("|"));
console.log(source.length, result[1] === nested);Result
A|1|B|[C] 2 true