📜  数组中的最小对象值 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:46.598000             🧑  作者: Mango

代码示例1
var list = [
{
'id':4,
'name':'nitin',
'group':'angularjs'
},
{
'id':1,
'name':'nitin',
'group':'angularjs'
},
{
'id':2,
'name':'nitin',
'group':'angularjs'
},
{
'id':3,
'name':'nitin',
'group':'angularjs'
}];

var result = list.reduce(function(res, obj) {
    return (obj.id < res.id) ? obj : res;
});

console.log(result);
 Run code snippetHide results