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)
我想知道这些数据的最高价格.我知道我可以遍历数组并收集数据,但最好的方法是什么?
这样的代码:
Math.max.apply(Math, prices.map(function(p) {return p.value;}));
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
105 次 |
最近记录: |