如何得到数组里面对象 中的最大值 一行代码 搞定
var arr = [
{id:1,name:'小李',age:23},
{id:2,name:'小明',age:24},
{id:3,name:'小王',age:25},
{id:4,name:'小马',age:29},
]
var maxNum = Math.max.apply(Math, arr.map(function(o) {return o.age}))
var minNum = Math.min.apply(Math, arr.map(function(o) {return o.age}))
console.log('我是年龄最大的',maxNum)
console.log('我是年龄最小的',minNum)