[英]Why does Array.prototype.reduce not have a thisObject parameter?
[英]Is it possible to manipulate the index parameter of Array.prototype.reduce?
通常,Array.prototype.reduce的索引值采用從0到Array.length的值。 是否有可能操縱該值,使其從Array.length開始並下降到0?
您可以始終為此使用Array.prototype.reduceRight() 。
不,但是您可以始終這樣做...
var yourNumber = arr.length - 1 - index;
...或Array.prototype.reduceRight()
將從最后一個索引循環到第一個(相反)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.