Math是数学函数,但又属于对象数据类型typeof Math=> ‘object’
console.dir(Math)查看Math的所有函数方法。
1,Math.abs()获取绝对值

2,Math.ceil() and Math.floor() 向上取整和向下取整

3,Math.round() 四舍五入
注意:正数时,包含5是向上取整,负数时包含5是向下取整。

4,Math.random() 取[0,1)的随机小数
案例1:获取[0,10]的随机整数

5,Math.max() and Max.min() 获取一组数据中的最大值和最小值

6,Math.PI 获取圆周率π 的值

7,Math.pow() and Math.sqrt()
Math.pow()获取一个值的多少次幂
Math.sqrt()对数值开方

案例
