File: index.html

package info (click to toggle)
jqapi 1.7%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch, wheezy
  • size: 3,288 kB
  • ctags: 76
  • sloc: makefile: 12
file content (66 lines) | stat: -rw-r--r-- 3,281 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!DOCTYPE html>
<html lang='en'><head><meta http-equiv='content-type' content='text/html; charset=UTF-8' /></head><body>
<div class="entry-content">
        <div class="entry-title roundTop">
          
          <h1 class="jq-clearfix">jQuery.merge()</h1>
          <div class="entry-meta jq-clearfix">
                        Categories:
            <span class="category"><a href="http://api.jquery.com/category/utilities/" title="View all posts in Utilities">Utilities</a></span>
  

          </div>

</div>
<div id="jQuery-merge1" class="entry method">
<h2 class="jq-clearfix roundTop section-title">
<span class="name">jQuery.merge( first, second )</span> <span class="returns">Returns: <a class="return" href="http://api.jquery.com/Types/#Array">Array</a></span>
</h2>
<div class="jq-box roundBottom entry-details">
<p class="desc"><strong>Description: </strong>Merge the contents of two arrays together into the first array. </p>
<ul class="signatures"><li class="signature" id="jQuery-merge-first-second">
<h4 class="name">
<span class="versionAdded">version added: <a href="/category/version/1.0/">1.0</a></span>jQuery.merge( first, second )</h4>
<p class="arguement"><strong>first</strong>The first array to merge, the elements of second added.</p>
<p class="arguement"><strong>second</strong>The second array to merge into the first, unaltered.</p>
</li></ul>
<div class="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>Prior to jQuery 1.4, the arguments should be true Javascript Array objects; use <code>$.makeArray</code> if they are not.</p>
</div>
<h3>Examples:</h3>
<div class="entry-examples" id="entry-examples">
<div id="example-0">
<h4>Example: <span class="desc">Merges two arrays, altering the first argument.</span>
</h4>
<pre class="prettyprint"><code class="example">$.merge( [0,1,2], [2,3,4] )</code></pre>
<h4>Result:</h4>
<pre><code class="results">[0,1,2,2,3,4] </code></pre>
</div>
<div id="example-1">
<h4>Example: <span class="desc">Merges two arrays, altering the first argument.</span>
</h4>
<pre class="prettyprint"><code class="example">$.merge( [3,2,1], [4,3,2] )  </code></pre>
<h4>Result:</h4>
<pre><code class="results">[3,2,1,4,3,2] </code></pre>
</div>
<div id="example-2">
<h4>Example: <span class="desc">Merges two arrays, but uses a copy, so the original isn't altered.</span>
</h4>
<pre class="prettyprint"><code class="example">var first = ['a','b','c'];
var second = ['d','e','f'];
$.merge( $.merge([],first), second);
      </code></pre>
<h4>Result:</h4>
<pre><code class="results">["a","b","c","d","e","f"] </code></pre>
</div>
</div>
</div>
</div>

        </div>

</body></html>