reduceRight

最后更新于:2022-04-02 00:00:17

## reduceRight + [link](./reduceRight "Link to this entry.") + [source](https://github.com/lodash/lodash/blob/4.5.0正式版/lodash.src.js#L8044 "View in source.") + [npm](https://www.npmjs.com/package/lodash.reduceright "See the npm package.") ``` _.reduceRight(collection, [iteratee=_.identity], [accumulator]) ``` 这个方法类似 `_.reduce` ,除了它是从右到左遍历的。 ### 参数 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] ```
';