minBy source npm

_.minBy(array, [iteratee=_.identity])

This method is like _.min except that it accepts iteratee which is invoked for each element in array to generate the criterion by which the value is ranked. The iteratee is invoked with one argument: (value).

Arguments

  1. array (Array)

    The array to iterate over.

  2. [iteratee=_.identity] (Function|Object|string)

    The function invoked per element.

Returns (*)

Returns the minimum value.

Example

var users = [
  { 'user': 'barney', 'age': 36 },
  { 'user': 'fred',   'age': 40 }
];

_.minBy(users, function(o) { return o.age; });
// => { 'user': 'barney', 'age': 36 }

// using the `_.property` callback shorthand
_.minBy(users, 'age');
// => { 'user': 'barney', 'age': 36 }