类型转换
<script type="text/javascript" language="javascript">
var a = "5";
document.write(a+1);//输出51
document.write("<br>");
a = parseInt(a);//将字符串转换为int类型
document.write(a+1);//输出6
document.write("<br>");
var b = "21.35";
document.write(b+1);//输出21.351
document.write("<br>");
b = parseFloat(b);
document.write(b+1);//输出22.35
document.write("<br>");
var c = "35abc";
c = parseInt(c);
document.write(c);//输出35,parseInt函数是从字符串的左边开始一个一个字符进行解析,遇到不能解析的字符就结束
document.write("<br>");
var d = "abc35";
d = parseInt(d);
document.write(d);//输出NaN(not a number)
</script>