_.nth

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

  1. array (Array): The array to query.
  2. [n=0] (number): The index of the element to return.

Returns

(*): Returns the nth element of array.

Example

var array = ['a', 'b', 'c', 'd'];
 
_.nth(array, 1);
// => 'b'
 
_.nth(array, -2);
// => 'c';