1 | import toInteger from './toInteger';
|
2 |
|
3 | /**
|
4 | * Creates a function that returns its nth argument.
|
5 | *
|
6 | * @static
|
7 | * @memberOf _
|
8 | * @since 4.0.0
|
9 | * @category Util
|
10 | * @param {number} [n=0] The index of the argument to return.
|
11 | * @returns {Function} Returns the new function.
|
12 | * @example
|
13 | *
|
14 | * var func = _.nthArg(1);
|
15 | *
|
16 | * func('a', 'b', 'c');
|
17 | * // => 'b'
|
18 | */
|
19 | function nthArg(n) {
|
20 | n = toInteger(n);
|
21 | return function() {
|
22 | return arguments[n];
|
23 | };
|
24 | }
|
25 |
|
26 | export default nthArg;
|