Array.concat

Joins two arrays and returns a new array.
Method of Array

Syntax

concat(arrayName2, arrayName3, ..., arrayNameN )

Parameters

Parameter Description
arrayName2... arrayName_N Arrays to concatenate to this array.

Description

concat does not alter the original arrays, but returns a "one level deep" copy that contains copies of the same elements combined from the original arrays. Elements of the original arrays are copied into the new array as follows:
Object references (and not the actual object): concat copies object references into the new array. Both the original and new array refer to the same object. If a referenced object changes, the changes are visible to both the new and original arrays.
Strings and numbers (not String and Number objects): concat copies strings and numbers into the new array. Changes to the string or number in one array does not affect the other arrays.
If a new element is added to either array, the other array is not affected.
The following code concatenates two arrays:

The following code concatenates three arrays:

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.