主题
reduceRight
js
_.reduceRight(collection, [iteratee=_.identity], [accumulator])此方法与 _.reduce 类似,不同之处在于它从右到左迭代 collection 的元素。
¥This method is like _.reduce except that it iterates over elements of collection from right to left.
新增于
¥Since
0.1.0
参数
¥Arguments
collection(数组|对象):要迭代的集合。¥
collection(Array|Object): The collection to iterate over.[iteratee=_.identity](函数):每次迭代调用的函数。¥
[iteratee=_.identity](Function): The function invoked per iteration.[accumulator](*):的逆;¥
[accumulator]()*: The initial value.
返回
¥Returns
(*):返回累积值。
¥()*: Returns the accumulated value.
示例
¥Example
js
var array = [[0, 1], [2, 3], [4, 5]];
_.reduceRight(array, function(flattened, other) {
return flattened.concat(other);
}, []);
// => [4, 5, 2, 3, 0, 1]