4.17.11
3.10.1
2.4.2
1.3.1
_.nth(array, [n=0])
Gets the element at index n
of array
. If n
is negative, the nth
element from the end is returned.
Since
4.11.0
Arguments
argument
array
[n=0]
type
Array
number
description
The array to query.
The index of the element to return.
Returns
(array)
Example
var array = ["a", "b", "c", "d"];
_.nth(array, 1);
// => 'b'
_.nth(array, -2);
// => 'c';
var array = ["a", "b", "c", "d"];
_.nth(array, 1);
// => 'b'
_.nth(array, -2);
// => 'c';