js中Math.max()求取数组中最大值

let arr = [3,2,4,1,8,6]
let maxValue = Math.max.apply(null,arr);
console.log(maxValue);

PS: Math.max()中的参数不可以传数组

 

 

let arr = [3,2,4,1,8,6]
let maxValue = Math.max(...arr);
console.log(maxValue);

 

posted @ 2019-02-20 23:18  灭世的蜜糖  阅读(5165)  评论(0)    收藏  举报