I have an array like this
var data = [
{ i: 0, j: 0, day: 5 },
{ i: 1, j: 0, day: 3 },
{ i: 1, j: 1, day: 5 },
{ i: 1, j: 2, day: 10 },
{ i: 2, j: 0, day: 5 },
{ i: 3, j: 0, day: 5 },
{ i: 4, j: 0, day: 6 },
{ i: 4, j: 1, day: 10 }
]
I want to return a single row from JSON with minimum day
value
For eg in the above array minimum day
is 3
and i want to get
{ i: 1, j: 0, day: 3 }
as output
I have tried this method
Math.min.apply(Math,data.map(function(item){return item.day}))
but it returns only the minimum day
One solution i found is using indexOf
method but i don't think its a good practice. Is there any shorthand method ??