_.findLast

_.findLast(collection, [predicate=_.identity], [fromIndex=collection.length-1])

This method is like _.find except that it iterates over elements of collection from right to left.

Since

2.0.0

Arguments

  1. collection (Array|Object): The collection to inspect.
  2. [predicate=_.identity] (Function): The function invoked per iteration.
  3. [fromIndex=collection.length-1] (number): The index to search from.

Returns

(*): Returns the matched element, else undefined.

Example

_.findLast([1, 2, 3, 4], function(n) {
  return n % 2 == 1;
});
// => 3
doc_Lodash
2016-11-27 16:36:54
Comments
Leave a Comment

Please login to continue.