3.3 JS内置的对象——Math

3.3 JS内置的对象——Math

  Math对象 ==>   一般用来执行js中的数学运算  

  Math.PI 圆周率

  Math.random() 获取随机数字 [0,1)

  Math.min(a,b) a和b中取小值

  Math.max(a,b) a和b中取大值

  Math.ceil(x) x上取整

  Math.floor(x) x下取整

  Math.round(x) x四舍五入

 

  Math.sin(x) x的正弦值

  Math.cos(x) x的余弦值

  Math.tan(x) x的正切值

  Math.pow(x,y) x的y次方

  Math.sqrt(x) x的平方根

  Math.abs(数字) 求一个数字的绝对值

 

 sin30°的值,Math.sin(Math.PI*1/6)

posted @ 2019-07-06 12:17  小小oRa  阅读(135)  评论(0)    收藏  举报