JavaScript Math 对象常用方法总结


Math.abs(x):可返回数的绝对值

Math.ceil(x):向上取整

Math.floor(x):向下取整

Math.max(x,y):最大值

Math.min(x,y):最小值

Math.random(x):随机数

Math.round(x):四舍五入

获取指定范围内的随机数

var x=Math.floor(Math.random()*(max-min+1))+min;

以上这篇JavaScript Math 对象常用方法总结就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持phpstudy。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3