Javascript Array reduceRight(callback, initialValue)

Description

Javascript Array reduceRight(callback, initialValue)


// Array.prototype.reduceRight
Array.prototype.reduceRight = function reduceRight(callback, initialValue) {
  var array = this, previousValue = initialValue || 0;

  for (var index = array.length - 1; index > -1; --index) {
    previousValue = callback.call(window, previousValue, array[index], index, array);
  }//from   w ww.ja v a2s. com

  return previousValue;
};



PreviousNext

Related