javascript的Math对象和全局函数

Math方法

表示数学的运算
静态方法,使用时Math.方法();
常用:
ceil ():向上舍入
floor ():向下舍入
round ():四舍五入
random ():伪随机数(0.1-1.0)
pow (x,y):返回x的y次幂

全局函数

常用:
eval ():执行Js代码,如果字符串是一个Js代码,使用此方法执行
encodeURI ||encodeURIComponent ():编码
decondeURI||decodeURIComponent ():解码
isNaN ():判断是否为数字
是数字,返回false
不是数字,返回true
parseInt ():类型转换

var str="123";
   document.write(str+1);//返回1231
   document.write("<hr/>");
   document.write(parseInt(str)+1);//返回124

猜你喜欢

转载自blog.csdn.net/tomorrow_cmm/article/details/89438186