mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Merge branch 'fix_reduceRight_initial_value' of http://github.com/mcmire/underscore
This commit is contained in:
@@ -112,7 +112,9 @@
|
||||
_.reduceRight = _.foldr = function(obj, iterator, memo, context) {
|
||||
if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
|
||||
if (context) iterator = _.bind(iterator, context);
|
||||
return obj.reduceRight(iterator, memo);
|
||||
var args = [iterator];
|
||||
if (memo !== undefined) args.push(memo);
|
||||
return obj.reduceRight.apply(obj, args);
|
||||
}
|
||||
var reversed = (_.isArray(obj) ? obj.slice() : _.toArray(obj)).reverse();
|
||||
return _.reduce(reversed, iterator, memo, context);
|
||||
|
||||
Reference in New Issue
Block a user