js 中 math 的方法

Math.min()      //获取一组数值中的最小值
Math.max()     //获取一组数值中的最大值

Math.ceil()      //将数值中向上舍入为最接近的整数
Math.floor()         //将数值中向下舍入为最接近的整数
Math.round()       //将数值中四舍五入为最接近的整数

Math.random()        //返回0-1之间的一个随机数,不包括0和1
Math.floor(Math.random() * 10 +1) 随机产生1-10之间的任意数

Math.abs(n)          //返回n的绝对值
Math.exp(n)           //返回 E 的n次幂 E:自然底数,近似值2.7183
Math.log(n)          //返回n的自然对数
Math.pow(n,p)        //返回n的p次幂
Math.sqrt(n)         //返回n的平方根

Math.cos(x)          //返回x的余弦值
Math.sin(x)          //返回x的正弦值
Math.tan(x)          //返回x的正切值
Math.acos(x)           //返回x的反余弦值
Math.asin(x)          //返回x的反正弦值
Math.atan(x)           //返回x的反正切值
Math.atan2(y,x)            //返回y/x的反正切值

Math.PI = 3.14 = 180°    // PI : 圆周率π 

原文地址:https://www.cnblogs.com/houBlogs/p/14544417.html