Finding the max value of an attribute in an array of objects

To find the maximum y value of the objects in array:

    Math.max.apply(Math, array.map(function(o) { return o.y; }))

or in more modern JavaScript:

    Math.max(...array.map(o => o.y))

Leave a Comment