Lodash nthArg method
语法
Creates a function that gets the argument at index n. If n is negative, the nth argument from the end is returned.
参数
[n=0] (number) − The index of the argument to return.
输出
(Function) − Returns the new pass-thru function.
实例
var _ = require('lodash');
var func = _.nthArg(1);
console.log(func('a', 'b', 'c', 'd'));
func = _.nthArg(2);
console.log(func('a', 'b', 'c', 'd'));
Save the above program in
tester.js. Run the following command to execute this program.
Command
输出