mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 15:57:48 +00:00
27 lines
919 B
JavaScript
27 lines
919 B
JavaScript
define(['../internal/baseCallback', '../internal/baseEachRight', '../internal/baseFind'], function(baseCallback, baseEachRight, baseFind) {
|
|
|
|
/**
|
|
* This method is like `_.find` except that it iterates over elements of
|
|
* `collection` from right to left.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collection
|
|
* @param {Array|Object|string} collection The collection to search.
|
|
* @param {Function|Object|string} [predicate=_.identity] The function invoked
|
|
* per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `predicate`.
|
|
* @returns {*} Returns the matched element, else `undefined`.
|
|
* @example
|
|
*
|
|
* _.findLast([1, 2, 3, 4], function(n) { return n % 2 == 1; });
|
|
* // => 3
|
|
*/
|
|
function findLast(collection, predicate, thisArg) {
|
|
predicate = baseCallback(predicate, thisArg, 3);
|
|
return baseFind(collection, predicate, baseEachRight);
|
|
}
|
|
|
|
return findLast;
|
|
});
|