diff --git a/lodash.js b/lodash.js index 4e163dd9f..c6a8ebad8 100644 --- a/lodash.js +++ b/lodash.js @@ -2152,7 +2152,7 @@ 'var noaccum = arguments.length < 3;\n' + 'if (thisArg) callback = iteratorBind(callback, thisArg)', 'beforeLoop': { - 'array': 'if (noaccum) result = collection[++index]' + 'array': 'if (noaccum) result = iteratee[++index]' }, 'inLoop': { 'array': diff --git a/test/test.js b/test/test.js index b4f747d25..98e991540 100644 --- a/test/test.js +++ b/test/test.js @@ -1115,6 +1115,30 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.reduce'); + + (function() { + _.each({ + 'literal': 'abc', + 'object': Object('abc') + }, + function(collection, key) { + test('should work with a string ' + key + ' for `collection` (test in IE < 9)', function() { + var args; + + var actual = _.reduce(collection, function(accumulator, value) { + args || (args = slice.call(arguments)); + return accumulator + value; + }); + + deepEqual(args, ['a', 'b', 1, collection]); + equal(actual, 'abc'); + }); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.reduceRight'); (function() {