1 var baseExtremum = require('./_baseExtremum'),
2 baseIteratee = require('./_baseIteratee'),
6 * This method is like `_.max` except that it accepts `iteratee` which is
7 * invoked for each element in `array` to generate the criterion by which
8 * the value is ranked. The iteratee is invoked with one argument: (value).
13 * @param {Array} array The array to iterate over.
14 * @param {Function|Object|string} [iteratee=_.identity] The iteratee invoked per element.
15 * @returns {*} Returns the maximum value.
18 * var objects = [{ 'n': 1 }, { 'n': 2 }];
20 * _.maxBy(objects, function(o) { return o.n; });
23 * // The `_.property` iteratee shorthand.
24 * _.maxBy(objects, 'n');
27 function maxBy(array, iteratee) {
28 return (array && array.length)
29 ? baseExtremum(array, baseIteratee(iteratee), gt)
33 module.exports = maxBy;