get largest number in object array javascript code example
Example 1: javascript array find highest value of array of objects by key
Math.max.apply(Math, array.map(function(o) { return o.y; }))
Example 2: javascript hwo to return largest value with index
var a = [0, 21, 22, 7];
var indexOfMaxValue = a.reduce((iMax, x, i, arr) => x > arr[iMax] ? i : iMax, 0);
document.write("indexOfMaxValue = " + indexOfMaxValue); // prints "indexOfMaxValue = 2"