Search code examples
javascriptarraysreduceecmascript-5

Is it possible to manipulate the index parameter of Array.prototype.reduce?


Normally the index value of Array.prototype.reduce takes the values from 0 until the Array.length. Is it possible to manipulate that value so that it starts from Array.length and descends to 0?


Solution

  • You can always use Array.prototype.reduceRight() for this.