Lodash reArg method
语法
Creates a function that invokes func with arguments arranged according to the specified indexes where the argument value at the first index is provided as the first argument, the argument value at the second index is provided as the second argument, and so on.
参数
func (Function) − The function to rearrange arguments for.
indexes (...(number|number[])) − The arranged argument indexes.
输出
(Function) − Returns the new function.
实例
var _ = require('lodash');
var rearged = _.rearg(function(a, b, c) {
return [a, b, c];
}, [2, 0, 1]);
console.log(rearged('b', 'c', 'a'));
Save the above program in
tester.js. Run the following command to execute this program.
Command
输出