Issue #103, change initial value detection for reduce()

This commit is contained in:
Jeremy Ashkenas
2011-07-13 12:21:08 -04:00
parent cd236d4c47
commit 174c897fce

View File

@@ -100,7 +100,7 @@
// **Reduce** builds up a single result from a list of values, aka `inject`,
// or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
_.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
var initial = memo !== void 0;
var initial = arguments.length > 2;
if (obj == null) obj = [];
if (nativeReduce && obj.reduce === nativeReduce) {
if (context) iterator = _.bind(iterator, context);