I have an array of objects. I want to find the "maximum" of this array based on a function that returns whichever object is bigger when given 2 objects.
function comparison(first, second) {
// ... arbitrary comparison based on properties...
return first; // or second
}
var a = [obj1, obj2, obj3];
var maxObj = ????(comparison);
What do I fill in here? What's elegant and short?