如何从嵌套结构中获取最高数字

And*_*old 0 javascript algorithm loops

我有一个类似的数据结构 - >

var prices = [
    {currency: '$', value: 52},
    {currency: '$', value: 139},
    {currency: '$', value: 31},
    {currency: '$', value: 5}
];
Run Code Online (Sandbox Code Playgroud)

我想知道这些数据的最高价格.我知道我可以遍历数组并收集数据,但最好的方法是什么?

Sam*_*rie 6

这样的代码:

Math.max.apply(Math, prices.map(function(p) {return p.value;}));
Run Code Online (Sandbox Code Playgroud)