Section 24.7. Array.concat( ): concatenate arrays


24.7. Array.concat( ): concatenate arrays

ECMAScript v3

24.7.1. Synopsis

array.concat(value, ...)

24.7.1.1. Arguments

value, ...

Any number of values to be concatenated with array.

24.7.1.2. Returns

A new array, which is formed by concatenating each of the specified arguments to array.

24.7.2. Description

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.

24.7.3. Example

 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]] 

24.7.4. See Also

 Array.join( ), Array.push( ), Array.splice( ) 




JavaScript. The Definitive Guide
JavaScript: The Definitive Guide
ISBN: 0596101996
EAN: 2147483647
Year: 2004
Pages: 767

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net