–通过“+”号或toString()方法将数值型转换成字符型
–通过parseInt()将字符型转换成整型
–通过parseFloat()将字符型转换成整型(要用到double型时为防止精度丢失,可以先乘100向上取整,再除100)
<script>
var i=3;
var j=10;
var a=j+i;
var b=i.toString();
//a=103;b=3
document.write(parseFloat("35ccc"));//35
document.write(parseFloat("35.34"));//35.34
document.write(parseFloat("35.34.11"));//35.34
document.write(parseFloat("qwqwe"));//NaN
document.write(parseFloat("0xA"));//0
document.write(parseInt("35.34"));//35
document.write(parseInt("0xC"));//12;0x开头,代表的是16进制数,0开头的,代表的是8进制数
</script>