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

,.
var array=[
  {
    "id": 52354541,
    "name": "",
    "value": "55"
},
{
    "id": 43563123,
    "name": "",
    "value": "88"
},
{
    "id": 32525763,
    "name": "",
    "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 want to modify this code if the return value is not value, but id.

< hr >

the code I"m 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;
            }
          });

array.reduce((p,v) => p.value < v.value ? v : p).id

you can sort it first (from big to small), and then take the first object

  

Math.max.apply (Math, array.map (function (item) {return item.id})

Menu