jQuery merge() function is used to merge the contents of two arrays together into the first array.
Syntax
jQuery.merge( first, second )
- first - The first array-like object to merge, the elements of second added.
- second - The second array-like object to merge into the first, unaltered.
Examples
Merges two arrays, altering the first argument.
$.merge( [ 0, 1, 2 ], [ 2, 3, 4 ] )
Result:
1
[ 0, 1, 2, 2, 3, 4 ]
Merges two arrays, altering the first argument.
$.merge( [ 3, 2, 1 ], [ 4, 3, 2 ] )
Result:
1
[ 3, 2, 1, 4, 3, 2 ]
Merges two arrays, but uses a copy, so the original isn't altered.
var first = [ "a", "b", "c" ];
var second = [ "d", "e", "f" ];
$.merge( $.merge( [], first ), second );
Result:
1
[ "a", "b", "c", "d", "e", "f" ]
Comments
Post a Comment