diff --git a/index.html b/index.html index 597d8f602..c8ad84562 100644 --- a/index.html +++ b/index.html @@ -225,7 +225,7 @@ _(lyrics).chain()
In addition, the - Array prototype's methods + Array prototype's methods are proxied through the chained Underscore object, so you can slip a reverse or a push into your chain, and continue to modify the array. @@ -247,17 +247,22 @@ _(lyrics).chain()
_.each([1, 2, 3], function(num){ alert(num); });
+=> alerts each number in turn...
+_.each({one : 1, two : 2, three : 3}, function(num, key){ alert(num); });
=> alerts each number in turn...
map_.map(list, iterator, [context])
Produces a new array of values by mapping each value in list
- through a transformation function (iterator). If the native
- map method exists, it will be used instead.
+ through a transformation function (iterator). If the native map method
+ exists, it will be used instead. If list is a JavaScript object,
+ iterator's arguments will be (value, key, list).
-_.map([1, 2, 3], function(num){ return num * 3 });
+_.map([1, 2, 3], function(num){ return num * 3; });
+=> [3, 6, 9]
+_.map({one : 1, two : 2, three : 3}, function(num, key){ return num * 3; });
=> [3, 6, 9]
@@ -270,7 +275,7 @@ _.map([1, 2, 3], function(num){ return num * 3 }); iterator.
-var sum = _.reduce([1, 2, 3], function(memo, num){ return memo + num }, 0);
+var sum = _.reduce([1, 2, 3], function(memo, num){ return memo + num; }, 0);
=> 6