<spanclass="name">jQuery.merge( first, second )</span><spanclass="returns">Returns: <aclass="return"href="http://docs.jquery.com/Types#Array">Array</a></span>
</h2>
<divclass=" entry-details">
<pclass="desc"><strong>Description: </strong>Merge the contents of two arrays together into the first array. </p>
<spanclass="versionAdded">version added: <ahref="/category/version/1.0/">1.0</a></span>jQuery.merge( first, second )</h4>
<pclass="arguement"><strong>first</strong>The first array to merge, the elements of second added.</p>
<pclass="arguement"><strong>second</strong>The second array to merge into the first, unaltered.</p>
</li></ul>
<divclass="longdesc">
<p>The <code>$.merge()</code> 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 <code>$.merge()</code> function is destructive. It alters the first parameter to add the items from the second. </p>
<p>If you need the original first array, make a copy of it before calling <code>$.merge()</code>. Fortunately, <code>$.merge()</code> itself can be used for this duplication:</p>
<pre>var newArray = $.merge([], oldArray);</pre>
<p>This shortcut creates a new, empty array and merges the contents of oldArray into it, effectively cloning the array.</p>
<p>The arguments should be true Javascript Array objects; use <code>$.makeArray</code> if they are not.</p>
</div>
<h3>Examples:</h3>
<divid="entry-examples"class="entry-examples">
<divid="example-0">
<h4>Example: <spanclass="desc">Merges two arrays, altering the first argument.</span>