js常用系统函数用法实例分析
本文实例讲述了js常用系统函数用法。分享给大家供大家参考。
具体代码如下:
<html>
<head>
</head>
<body>
<scripttype="text/javascript">
//1.escape()函数,把字符串转成各计算机平台通用的unicode编码;解码(转回去)则用enescape()。
varstr='王美人';
document.write(escape(str));
document.write("<br/>");
//2.字符串转化为整型,或转化为浮点型。如果原字符串age不是以数字开头,结果则是NaN。 varage="26.9hellowworld"; document.write(parseInt(age));//parseInt()函数 document.write("<br/>"); document.write(parseFloat(age));//parseFloat()函数 document.write("<br/>");
//3.判断一个值/变量值,是不是非数字。 varnum="30.9abc"; if(isNaN(num)){ document.write("num是一个非数字"); }else{ document.write("num是一个数字"); } document.write("<br/>");
//4.判断一个值/变量值,是不是有穷的 varresult=10/0; if(isFinite(result)){ document.write("result变量的值有穷的"); }else{ document.write("result变量的值无穷的"); }
</script> </body> </html>
热门推荐
10 感谢韩语老师祝福语简短
11 升职文案高级祝福语简短
12 花童结婚祝福语大全简短
13 向国庆送祝福语简短
14 什么寄语简短祝福语女生
15 客户回礼祝福语大全简短
16 女孩生日祝福语简短创意
17 家长回复节日祝福语简短
18 给外婆敬酒祝福语简短