document.write("整数转换函数:parseInt(数据,底数)<br>");
document.write("10101=>" + parseInt("10101",2)+"<br>");
document.write("77=>" + parseInt("77",8)+"<br>");
document.write("2A3B=>" + parseInt("2A3B",16)+"<br>");
document.write("077=>" + parseInt("077")+"<br>");
document.write("0X2A3B=>" + parseInt("0X2A3B")+"<br>");
document.write("浮点数转换函数:parseFloat(数据)<br>");
var str = "12.345";
var str1 = str + 6;
var str2 = parseFloat(str) + 6;
document.write(str1 + "=>" + parseFloat(str1)+"<br>");
document.write(str1 + "=>" + parseFloat(str2)+"<br>");
document.write("34.89a23=>" + parseFloat("34.89a23")+"<br>");
document.write("数字判断函数:isNaN<br>");
document.write("4是数字:"+!isNaN(4)+"<br>");
document.write("ffff是数字:"+!isNaN("ffff")+"<br>");
结果:
10101=>21
77=>63
2A3B=>10811
077=>63
0X2A3B=>10811
浮点数转换函数:parseFloat(数据)
12.3456=>12.3456
12.3456=>18.345
34.89a23=>34.89
数字判断函数:isNaN
4是数字:true
ffff是数字:false