Lodash _.reduceRight

2021-09-24 10:11 更新

_.reduceRight(collection, [iteratee=_.identity], [accumulator])

这个方法类似_.reduce ,除了它是从右到左遍历collection(集合)中的元素的。

添加版本

0.1.0

参数

  1. collection (Array|Object): 用来迭代的集合。
  2. [iteratee=_.identity] (Function): 每次迭代调用的函数。
  3. [accumulator] (*): 初始值。

返回

(*): 返回累加后的值。

例子

var array = [[0, 1], [2, 3], [4, 5]];
 _.reduceRight(array, function(flattened, other) {  return flattened.concat(other);}, []);
// => [4, 5, 2, 3, 0, 1]


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号