Find the maximum value of an attribute in the array of objects, and then return the other attribute values of the item

  node.js, question
There is an array containing objects.
 var array=[
 bracket
 "id": 52354541,
 "name": "Ratio",
 "value": "55"
 },
 bracket
 "id": 43563123,
 "name": "Ratio",
 "value": "88"
 },
 bracket
 "id": 32525763,
 "name": "Ratio",
 "value": "76"
 }];

If you are looking for the maximum value, you can directly
Math.max.apply(Math, array.map(function(item) {return item.value})) // 88
But now I think the return value is not value, but id.


The code I am using now is, how can I write it better? ?

let max = 0;
 let maxId = '';
 res.data.map(item => {
 if(item.orgAccumulative > max) {
 max = item.orgAccumulative;
 maxId = item.id;
 bracket
 });

You can sort first (from large to small) and then take the first object.

var array=[
 bracket
 "id": 52354541,
 "name": "Ratio",
 "value": "55"
 },
 bracket
 "id": 43563123,
 "name": "ratio ratio",
 "value": "88"
 },
 bracket
 "id": 32525763,
 "name": "Satisfaction Ratio",
 "value": "76"
 }];
 console.log(array.sort(function(a, b){return a.value < b.value})[0].id) // 43563123