js生成随机数主要用了math对象的random方法.用法:Math.random( )
Math.ceil() 返回大于等于数字参数的最小整数(取整函数),对数字进行上舍入
Math.floor() 返回小于等于数字参数的最大整数,对数字进行下舍入
Math.round() 返回数字最接近的整数,四舍五入
Math.sqrt()//计算平方根
Math.cbrt()//计算立方根
Math.hypot(x,y)//计算 (x的平方+y的平方)的平方根
Math.pow(a,b)//计算a的b次方
Math.exp(x)//计算e^x的值
Math.max();//计算最大值
Math.min();//计算最小值
Math.abs求绝对值
网友评论