It will iterate through each element of the provided values array and return the result of invoking iteratee function/property for each element to produce the desired number, to then be compared with other result numbers to find the maximum value.
values
iteratee
number
maximum
The array to iterate over.
The function/property to get the value per element.
The maximum value.
1.0.0
maxBy([1, 2, 3], number => number); // => 3 Copy
maxBy([1, 2, 3], number => number); // => 3
maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], ({ a }) => a); // => 3 Copy
maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], ({ a }) => a); // => 3
maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], "a"); // => 3 Copy
maxBy([{ a: 1 }, { a: 2 }, { a: 3 }], "a"); // => 3
It will iterate through each element of the provided
values
array and return the result of invokingiteratee
function/property for each element to produce the desirednumber
, to then be compared with other resultnumber
s to find themaximum
value.