Javascript Array reduceRight(fn, previous)

Description

Javascript Array reduceRight(fn, previous)


Array.prototype.reduceRight = function reduce(fn, previous) {

  if (typeof fn != "function") {
    throw new TypeError(fn + " is not a function");
  }/* ww  w  .j  a v a2 s.co  m*/

  for (var i = this.length - 1; i >= 0; --i) {
    if (this.hasOwnProperty(i)) {
      previous = fn.call(this, previous, this[i], i, this);
    }
  }

  return previous;
}



PreviousNext

Related