Skip to content

jQuery.merge: add note about it correcting the length #692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions entries/jQuery.merge.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<desc>Merge the contents of two arrays together into the first array. </desc>
<signature>
<added>1.0</added>
<argument name="first" type="Array">
<desc>The first array to merge, the elements of second added.</desc>
<argument name="first" type="ArrayLikeObject">
<desc>The first array-like object to merge, the elements of second added.</desc>
</argument>
<argument name="second" type="Array">
<desc>The second array to merge into the first, unaltered.</desc>
<argument name="second" type="ArrayLikeObject">
<desc>The second array-like object to merge into the first, unaltered.</desc>
</argument>
</signature>
<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>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 <code>length</code> and numeric index properties of the first object to include 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><code>
var newArray = $.merge([], oldArray);
Expand Down
4 changes: 2 additions & 2 deletions pages/Types.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<li class="toclevel-2"><a href="#Array.3CType.3E_Notation"><span class="toctext">Array&lt;Type&gt; Notation</span></a></li>
</ul>
</li>
<li class="toclevel-1"><a href="#ArrayLikeObjects"><span class="toctext">Array-Like Objects</span></a></li>
<li class="toclevel-1"><a href="#ArrayLikeObject"><span class="toctext">Array-Like Object</span></a></li>
<li class="toclevel-1"><a href="#PlainObject"><span class="toctext">PlainObject</span></a></li>
<li class="toclevel-1"><a href="#Date"><span class="toctext">Date</span></a></li>
<li class="toclevel-1"><a href="#Function"><span class="toctext">Function</span></a>
Expand Down Expand Up @@ -412,7 +412,7 @@ <h3 id="Array.3CType.3E_Notation"> Array&lt;Type&gt; Notation </h3>
</pre>
<p>This indicates that the method doesn't only expect an array as the argument, but also specifies the expected type. The notation is borrowed from Java 5's generics notation (or C++ templates).
</p>
<h2 id="ArrayLikeObjects">Array-Like Objects</h2>
<h2 id="ArrayLikeObject">Array-Like Object</h2>
<p>Either a true JavaScript Array or a JavaScript Object that contains a nonnegative integer <code>length</code> property and index properties from <code>0</code> up to <code>length - 1</code>. This latter case includes array-like objects commonly encountered in web-based code such as the <code>arguments</code> object and the <code>NodeList</code> object returned by many DOM methods.</p>
<p>When a jQuery API accepts either plain Objects or Array-Like objects, a plain Object with a numeric <code>length</code> property will trigger the Array-Like behavior.</p>
<h2 id="PlainObject"> PlainObject </h2>
Expand Down