用于数学运算
不需要创建对象,可以直接使用其中的API
PI 圆周率
console.log(Math.PI);==>3.141592653589793
abs 获取绝对值
console.log(Math.abs(-1));===>1
ceil 向上取整
console.log(Math.ceil(4.99));===>5
console.log(Math.ceil(3.05));===>4
floor 向下取整
console.log(Math.floor(4.99));==>4
console.log(Math.floor(3.45));==>3
round 四舍五入取整
console.log(Math.round(4.99));==>5
console.log(Math.round(4.45));==>4
max 取一组数字最大值
console.log(Math.max(4,2,1,3,6));==>6
min 取一组数字最小值
console.log(Math.min(4,2,1,3,6));==>1
pow 取x的y次方
console.log(Math.pow(5,2));==>25 5的平方
random 取随机数,范围0~1 >=0 <1
console.log(Math.random());==>0.28856575735647283