jQuery.merge( first, second )Returns: Array
Description: Merge the contents of two arrays together into the first array.
-
version added: 1.0jQuery.merge( first, second )
-
firstType: ArrayLikeObjectThe first array-like object to merge, the elements of second added.
-
secondType: ArrayLikeObjectThe second array-like object to merge into the first, unaltered.
-
$.merge()
operation forms an array that contains all elements from the two arrays. The orders of items in the arrays are preserved, with items from the second array appended. The $.merge()
function is destructive. It alters the length
and numeric index properties of the first object to include items from the second.
$.merge()
. Fortunately, $.merge()
itself can be used for this duplication:
1
|
|
$.makeArray
if they are not.
Examples:
Example 1
1
|
|
Result:
1
|
|
Example 2
1
|
|
Result:
1
|
|
Example 3
1
2
3
|
|
Result:
1
|
|