function reduce(collection, callback, accumulator, thisArg) {
      var noaccum = arguments.length < 3;
      callback = lodash.createCallback(callback, thisArg, 4);

      if (isArray(collection)) {
        var index = -1,
            length = collection.length;

        if (noaccum) {
          accumulator = collection[++index];
        }
        while (++index < length) {
          accumulator = callback(accumulator, collection[index], index, collection);
        }
      } else {
        baseEach(collection, function(value, index, collection) {
          accumulator = noaccum
            ? (noaccum = false, value)
            : callback(accumulator, value, index, collection)
        });
      }
      return accumulator;
    }
Reduces a collection to a value which is the accumulated result of running
each element in the collection through the callback, where each successive
callback execution consumes the return value of the previous execution. If
`accumulator` is not provided the first element of the collection will be
used as the initial `accumulator` value. The callback is bound to `thisArg`
and invoked with four arguments; (accumulator, value, index|key, collection).

@static
@memberOf _
@alias foldl, inject
@category Collections
@param {Array|Object|string} collection The collection to iterate over.
@param {Function} [callback=identity] The function called per iteration.
@param {*} [accumulator] Initial value of the accumulator.
@param {*} [thisArg] The `this` binding of `callback`.
@returns {*} Returns the accumulated value.
@example

var sum = _.reduce([1, 2, 3], function(sum, num) {
  return sum + num;
});
// => 6

var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
  result[key] = num * 3;
  return result;
}, {});
// => { 'a': 3, 'b': 6, 'c': 9 }