Lodash教程

Lodash nthArg method

语法

_.nthArg([n=0])
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

\>node tester.js

输出

b
c
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4