Lodash reduceRight method
语法:
_.reduceRight(collection, [iteratee=_.identity], [accumulator])
This method is like _.reduce except that it iterates over elements of collection from right to left.
参数:
collection (Array|Object) − The collection to iterate over.
[iteratee=_.identity] (Function) − The function invoked per iteration.
[accumulator] (*) − The initial value.
输出:
(*) − Returns the accumulated value.
例子:
var _ = require('lodash');
var list = [[0, 1], [2, 3], [4, 5]];
var result = _.reduceRight(list, function(flattened, other) {
return flattened.concat(other);
}, []);
console.log(result);
Save the above program in
tester.js. Run the following command to execute this program.
命令:
输出: