![]() |
VOOZH | about |
Lodash _.nth() method is used to return the nth index of the element. For a negative value of n, it returns the nth element from the end.
_.nth(array, n);Example 1: In this example, It returns the third element of an array.
Output:
4Example 2: In this example, It returns the third element from the end of an array because the value of n is negative.
Output:
3Example 3: In this example, It returns undefined because there is no element at index 8.