美文网首页
JS Math对象

JS Math对象

作者: Cherry丶小丸子 | 来源:发表于2019-01-28 16:23 被阅读0次

    Math 对象用于执行数学任务。
    Math 对象并不像 Date 和 String 那样是对象的类,因此没有构造函数 Math()。

    Math.ceil(x) //向上取整    
    Math.round(x) //四舍五入
    Math.floor(x) // 向下取整
    Math.abs(x) //返回x的绝对值
    Math.exp(x) //返回Ex的指数
    Math.min(x,y,z......n) //返回 x,y,z,...,n 中的最小值
    Math.max(x,y,z......n) //返回 x,y,z,...,n 中的最大值
    Math.valueOf() //返回Math对象原始值
    Math.random() //返回0.0-1.0之间的随机数
    
    Math.sin(x) //返回x的正弦值
    Math.cos(x) //返回 x 的余弦值
    Math.tan(x) //返回x的正切值
    
    Math.asin(x) //返回 x 的反正弦值
    Math.acos(x) //返回 x 的反余弦值
    Math.atan(x) //以介于 -PI/2 与 PI/2 弧度之间的数值来返回 x 的反正切值
    
    Math.atan2(x,y) //返回从 x 轴到点 (x,y) 的角度(介于 -PI/2 与 PI/2 弧度之间)
    
    Math.log(x) //返回数的自然对数(底为e)
    Math.pow(x,y) //返回 x 的 y 次幂
    Math.sqrt(x) //返回x的平方根
    

    相关文章

      网友评论

          本文标题:JS Math对象

          本文链接:https://www.haomeiwen.com/subject/bfdvjqtx.html