Answers for "min object value in array"

0

min object value in array

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
Posted by: Guest on October-27-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language