Math对象

    alert(Math.random())//[0,1)之间的随机数
    alert(Math.round(2.8)) //四舍五入,3


   //获取1-100的随机整数,包括1和100
    var num=10*Math.random();
    num=Math.round(num);
    alert(num);


       //Math是内置对象--拿来即用
    alert(Math.pow(2,4)) //2的4次方

    window.alert(123) //alert是Window的方法


abs(x)    返回数的绝对值。
exp(x)    返回 e 的指数。
floor(x)对数进行下舍入。
log(x)    返回数的自然对数(底为e)。
max(x,y)    返回 x 和 y 中的最高值。
min(x,y)    返回 x 和 y 中的最低值。
pow(x,y)    返回 x 的 y 次幂。
random()    返回 0 ~ 1 之间的随机数。
round(x)    把数四舍五入为最接近的整数。
sin(x)    返回数的正弦。
sqrt(x)    返回数的平方根。
tan(x)    返回角的正切。
原文地址:https://www.cnblogs.com/jiefangzhe/p/8128253.html