2 * A specialized version of `_.reduce` for arrays without support for
6 * @param {Array} [array] The array to iterate over.
7 * @param {Function} iteratee The function invoked per iteration.
8 * @param {*} [accumulator] The initial value.
9 * @param {boolean} [initAccum] Specify using the first element of `array` as
11 * @returns {*} Returns the accumulated value.
13 function arrayReduce(array, iteratee, accumulator, initAccum) {
15 length = array == null ? 0 : array.length;
17 if (initAccum && length) {
18 accumulator = array[++index];
20 while (++index < length) {
21 accumulator = iteratee(accumulator, array[index], index, array);
26 module.exports = arrayReduce;