function arrayReduce(array, iteratee, accumulator, initFromArray) {
  var index = -1;
  var iterable = array;
  var result = accumulator;

  if (!Array.isArray(array)) {
    iterable = Array.from(array);
  }

  var length = iterable.length;

  if (initFromArray && length) {
    index += 1;
    result = iterable[index];
  }

  index += 1;

  while (index < length) {
    result = iteratee(result, iterable[index], index, iterable);
    index += 1;
  }

  return result;
}
A specialized version of `.reduce` for arrays without support for callback
shorthands and `this` binding.

{@link https://github.com/lodash/lodash/blob/master/lodash.js}

@param {Array} array The array to iterate over.
@param {Function} iteratee The function invoked per iteration.
@param {*} [accumulator] The initial value.
@param {Boolean} [initFromArray] Specify using the first element of `array` as the initial value.
@returns {*} Returns the accumulated value.