findLast.js 745 B

12345678910111213141516171819202122232425
  1. var baseEachRight = require('../internal/baseEachRight'),
  2. createFind = require('../internal/createFind');
  3. /**
  4. * This method is like `_.find` except that it iterates over elements of
  5. * `collection` from right to left.
  6. *
  7. * @static
  8. * @memberOf _
  9. * @category Collection
  10. * @param {Array|Object|string} collection The collection to search.
  11. * @param {Function|Object|string} [predicate=_.identity] The function invoked
  12. * per iteration.
  13. * @param {*} [thisArg] The `this` binding of `predicate`.
  14. * @returns {*} Returns the matched element, else `undefined`.
  15. * @example
  16. *
  17. * _.findLast([1, 2, 3, 4], function(n) {
  18. * return n % 2 == 1;
  19. * });
  20. * // => 3
  21. */
  22. var findLast = createFind(baseEachRight, true);
  23. module.exports = findLast;