Math.max

Math.max(value1, value2);

若想处理数组中的值:

let values = [25, 50, 75, 100]
console.log(Math.max.apply(Math, values)); // 100

ES6的方法:

let values = [25, 50, 75, 100]
// 等价于 console.log(Math.max(25, 50, 75, 100));
console.log(Math.max(...values));

let values = [-25, -50, -75, -100]
console.log(Math.max(...values, 0));

posted @ 2017-05-17 13:42  SuLingLiu  阅读(249)  评论(0编辑  收藏  举报