I am looking to retrieve the value of the property b
from the object that has the highest value of the property a
.
var myArr = [
{
a: 1,
b: 15
},
{
a: 2,
b: 30
}
];
Although I attempted the following code, it currently only returns the highest value of a
, rather than b
.
var res = Math.max.apply(Math,myArr.map(function(o){return o.a;});
var blah = getByValue(myArr);