November 2001
Intermediate to advanced
936 pages
68h 43m
English
Array.concat( ) — concatenate arrays
JavaScript 1.2; JScript 3.0; ECMAScript v3
array.concat(value, ...)
value, ...
Any number of values to be concatenated with
array.
A new array, which is formed by concatenating each of the specified
arguments to array.
concat( ) creates and returns a new array that is
the result of concatenating each of its arguments to
array. It does not modify
array. If any of the arguments to
concat( ) is itself an array, the elements of that
array are concatenated, rather than the array itself.
var a = [1,2,3]; a.concat(4, 5) // Returns [1,2,3,4,5] a.concat([4,5]); // Returns [1,2,3,4,5] a.concat([4,5],[6,7]) // Returns [1,2,3,4,5,6,7] a.concat(4, [5,[6,7]]) // Returns [1,2,3,4,5,[6,7]]