主题
nthArg
js
_.nthArg([n=0])
创建一个获取索引 n
处的参数的函数。如果 n
为负,则返回从末尾开始的第 n 个参数。
¥Creates a function that gets the argument at index n
. If n
is negative, the nth argument from the end is returned.
新增于
¥Since
4.0.0
参数
¥Arguments
[n=0]
(数值):要返回的参数的索引。¥
[n=0]
(number): The index of the argument to return.
返回
¥Returns
(函数):返回新的传递函数。
¥(Function): Returns the new pass-thru function.
示例
¥Example
js
var func = _.nthArg(1);
func('a', 'b', 'c', 'd');
// => 'b'
var func = _.nthArg(-2);
func('a', 'b', 'c', 'd');
// => 'c'