Find the best element of an array, where "best" is defined by some given criteria.
Param: array
The array to traverse and find the best element of.
Param: optimizer
Either a key on the objects we're looking at that corresponds to numerical values, or a function for mapping these objects to numbers. Essentially, some way of assigning value to the elements of the array.
Param: reverse
Make this true to find the worst element of the array, and false to find the best. Defaults to false.
Find the best element of an array, where "best" is defined by some given criteria.
Param: array
The array to traverse and find the best element of.
Param: optimizer
Either a key on the objects we're looking at that corresponds to numerical values, or a function for mapping these objects to numbers. Essentially, some way of assigning value to the elements of the array.
Param: reverse
Make this true to find the worst element of the array, and false to find the best. Defaults to false.
Returns
Best element by optimizer function