![]() |
VOOZH | about |
Lodash _.last() method is used to get the last element of the array i.e. (n-1)th element. so it returns the value of the last index of an array.
_.last(array);Example 1: In this example, we are printing the value of the last index for a given array by the use of the _.last() method.
Output:
👁 ImageExample 2: In this example, we are printing the value of the last index for a given array by the use of the _.last() method. but the array is empty so it is returning undefined.