这个方法就像_.reduce
,不同的是它遍历collection
从右到左的元素。
0.1.0
collection
(Array | Object):迭代的集合。 [iteratee=_.identity]
(Function):每次迭代调用的函数。 [accumulator]
(*):初始值。 (*):返回累计值。
var array = [[0, 1], [2, 3], [4, 5]]; _.reduceRight(array, function(flattened, other) { return flattened.concat(other); }, []); // => [4, 5, 2, 3, 0, 1]Try in REPL