![]() |
VOOZH | about |
Lodash _.findLast() method iterates over the elements in a collection from the right to the left. It is almost the same as _.find() method.
_.findLast(collection, predicate, fromIndex);This method returns the element that matches, else undefined.
Example 1: In this example, we are getting the last existing element in an array which is satisfying the given condition in a function by the use of the lodash _.findLast() method.
Output:
5Example 2: In this example, we are getting the last existing element in an array which is satisfying the given condition in a function by the use of the lodash _.findLast() method.
Output:
6
55Example 3: In this example, we are getting undefined as the last existing element in an array which is satisfying the given condition in a function is not present.
Output:
undefined