Math
定义:数学函数 “它是一个标准特殊对象”,Math对象中包含了很多操作“数字/几何/数学”的方法
Math.abs([value]):获取绝对值"取正数值"
Math.abs(-1)//1
Math.ceil():向上取整
Math.ceil(1.2)
2
Math.ceil(-1.6)
-1
Math.floor():向下取整
Math.floor(1.8)
1
Math.floor(-1.1)
-2
Math.round():四舍五入
Math.round(1.5)
2
Math.round(-1.5)
-1
Math.round(-1.51)
-2
Math.random():获取0~1 之间的随机数[0,1]
Math.max/Math.min 获取最大值和最小值
Math.pow(n,m):获取n的m次方
Math.sqrt() 开平方
探索:获取n~m之间的随机整数[n,m] 前提:N<M;
公式:Math.round(Math.random()*(m-n)+n);