Nodejs Array Reduce reduceRight2(pasteback, initial)

Here you can find the source of reduceRight2(pasteback, initial)

Method Source Code

Array.prototype.reduceRight2 = function(pasteback, initial){
   for(var i = this.length
        , value = arguments.length>1 ? initial : this[--i]
   ; i--;){//from   w  ww . j  a  va 2  s .com
      value = pasteback(value, this[i], i, this);
   }
   return value;
};

Related

  1. reduce(testFunction,initialValue)
    Array.prototype.reduce = function(testFunction,initialValue){
      var accumulatedValue,counter;
      if(this.length == 0){
        return this;
      }else{
        if(arguments.length == 1){
          counter = 1;
          accumulatedValue = this[0];
        }else if(arguments.length >= 2){
    ...
    
  2. reduce(testFunction,initialValue)
    Array.prototype.reduce = function(testFunction,initialValue){
      var accumulatedValue,counter;
      if(this.length == 0){
        return this;
      }else{
        if(arguments.length == 1){
          counter = 1;
          accumulatedValue = this[0];
        }else if(arguments.length >= 2){
    ...
    
  3. reduce.call(str, (trav, char)>
    'use strict';
    class PrefixTree {
        constructor() {
            this.root = {};
        insert(str) {
            Array.prototype.reduce.call(str, (trav, char) => {
                if (!trav[char]) {
                    trav[char] = {};
    ...
    
  4. reduceRight(aggregate, initial)
    Array.prototype.reduceRight = function(aggregate, initial) {
      const len = this.length;
      let startIndex = len - 1;
      if(typeof initial === 'undefined') {
        initial = this[0];
        startIndex = len - 2;
      for(let i = startIndex; i >= 0; i -= 1) {
        initial = aggregate(initial, this[i], i, this);
    ...
    
  5. reduceRight(fun /*, initial*/)
    Array.prototype.reduceRight = function(fun ) {
        var len = this.length >>> 0;
        if (typeof fun != "function") {
            throw new TypeError();
        if (len == 0 && arguments.length == 1) {
            throw new TypeError();
        var i = len - 1;
    ...
    
  6. _reduce(f)
    Array.prototype._reduce = function(f){
        let acc = this[0];
        for(let i = 1; i < this.length; i++){
            acc = f(acc,this[i])
        return acc;