Skip to content

Commit 3ea0ddc

Browse files
committed
1 parent d8a6b7f commit 3ea0ddc

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

entries/jQuery.map.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</signature>
2222
<desc>Translate all items in an array or object to new array of items.</desc>
2323
<longdesc>
24-
<p>If you wish to process a jQuery object — for example, <code>$('div').map( callback );</code> — use <a href="/jQuery.map/">.map()</a> instead. </p>
24+
<p>If you wish to process a jQuery object — for example, <code>$('div').map( callback );</code> — use <a href="/map/">.map()</a> instead. </p>
2525
<p>The <code>$.map()</code> method applies a function to each item in an array or object and maps the results into a new array. <strong>Prior to jQuery 1.6</strong>, <code>$.map()</code> supports traversing <em>arrays only</em>. <strong>As of jQuery 1.6</strong> it also traverses objects.</p>
2626
<p>Array-like objects &#x2014; those with a <code>.length</code> property <em>and</em> a value on the <code>.length - 1</code> index &#x2014; must be converted to actual arrays before being passed to <code>$.map()</code>. The jQuery library provides <a href="http://api.jquery.com/jQuery.makeArray/">$.makeArray()</a> for such conversions.</p>
2727
<pre>
@@ -47,7 +47,7 @@ $.map( realArray, function(val, i) {
4747
</ul>
4848
</longdesc>
4949
<example>
50-
<desc>A couple examples of using .map()</desc>
50+
<desc>Use $.map() to change the values of an array.</desc>
5151
<code><![CDATA[
5252
var arr = [ "a", "b", "c", "d", "e" ];
5353
$("div").text(arr.join(", "));
@@ -81,7 +81,7 @@ $.map( realArray, function(val, i) {
8181
<results><![CDATA[[4, 5, 6] ]]></results>
8282
</example>
8383
<example>
84-
<desc>Maps the original array to a new one and adds 1 to each value if it is bigger then zero, otherwise it's removed.</desc>
84+
<desc>Map the original array to a new one, adding 1 to each value if it is bigger then zero and removing it if not.</desc>
8585
<code><![CDATA[$.map( [0,1,2], function(n){
8686
return n > 0 ? n + 1 : null;
8787
});]]></code>
@@ -101,15 +101,15 @@ var dimensions = { width: 10, height: 15, length: 20 };
101101
dimensions = $.map( dimensions, function( value, index ) {
102102
return value * 2;
103103
}); ]]></code>
104-
<results><![CDATA[[20, 30, 40] ]]></results>
104+
<results><![CDATA[ [20, 30, 40] ]]></results>
105105
</example>
106106
<example>
107107
<desc>Map an object's keys to an array.</desc>
108108
<code><![CDATA[
109-
var dimensions = { width: 10, height: 15, length: 20 },
110-
keys = $.map( dimensions, function( value, index ) {
111-
return index;
112-
}); ]]></code>
109+
var dimensions = { width: 10, height: 15, length: 20 };
110+
var keys = $.map( dimensions, function( value, key ) {
111+
return key;
112+
}); ]]></code>
113113
<results><![CDATA[["width", "height", "length"] ]]></results>
114114
</example>
115115
<example>
@@ -121,15 +121,15 @@ $.map( [0,1,2,3], function (a) {
121121
<results><![CDATA[[0, 1, 4, 9] ]]></results>
122122
</example>
123123
<example>
124-
<desc>Remove items by returning <code>null</code> from the function. This removes any numbers less than 50, and the rest are decreased by 45.</desc>
124+
<desc>Map the original array to a new one, removing numbers less than 50 by returning <code>null</code> and subtracting 45 from the rest.</desc>
125125
<code><![CDATA[
126126
$.map( [0, 1, 52, 97], function (a) {
127127
return (a > 50 ? a - 45 : null);
128128
});]]></code>
129129
<results><![CDATA[[7, 52] ]]></results>
130130
</example>
131131
<example>
132-
<desc>Augmenting the resulting array by returning an array inside the function.</desc>
132+
<desc>Augment the resulting array by returning an array inside the function.</desc>
133133
<code><![CDATA[var array = [0, 1, 52, 97];
134134
array = $.map(array, function(a, index) {
135135
return [a - 45, index];

0 commit comments

Comments
 (0)