JS里有关Math的api
取得最大值和最小值
console.log(Math.min(1, 2, 3, 4, 5, 1, 2))
console.log(Math.max(1, 2, 3, 4, 5, 1, 2))
let grade = [100, 60, 78, 99, 56]
console.log(Math.max(grade))
console.log(Math.max(...grade))
console.log(Math.min.apply(null, grade))
向上取整(天花板)和向下取整(地板)以及四舍五入
console.log(Math.ceil(3.14))
console.log(Math.floor(3.14))
console.log(Math.round(3.14))
console.log(Math.round(3.54))
随机数
console.log(Math.random())
console.log(Math.random() * 5)
console.log(2 + Math.floor(Math.random() * (8 - 2 + 1)))
console.log(2 + Math.ceil(Math.random() * (8 - 2)))