reduceRight()方法将数组元素计算为一个值(从右到左),以将其简化为单个值。
reduceRight() - 语法
array.reduceRight(callback[, initialValue]);
callback - 对数组中的每个值执行的函数。
initialValue - 用作首次调用回调的第一个参数的对象。
reduceRight() - 返回值
返回数组的缩减右单值。
reduceRight() - 示例
var total=[0, 1, 2, 3].reduceRight(function(a, b){ return a + b; }); console.log("total is : " + total );
运行上面代码输出
total is : 6
参考链接
https://www.learnfk.com/es6/es6-array-method-reduceright.html
标签:es6,教程,initialValue,reduceRight,无涯,数组,array,total From: https://blog.51cto.com/u_14033984/9569551