<script language="javascript" type="text/javascript">
//boolean()强制转换,当参数为空字符串和null时,得到false
document.write("强制转换<br />");
document.write(Boolean('')+"<br />");
document.write(Boolean(100)+"<br />");
document.write(Boolean(null)+"<br />");
document.write(Boolean(new Object())+"<br />");
//转换
var sColor="violet";
document.write(sColor.length,"<br />");
var bFound=false;
document.write(bFound.toString(),"<br />");
var iNum=10;
document.write("10的二进制数为",iNum.toString(2),"<br />");
document.write("10的八进制数为",iNum.toString(8),"<br />");
document.write("10的十进制数为",iNum.toString(10),"<br />");
//转换成数字
function testFunction(){}
document.write(Number(testFunction()),"<br />");
document.write(Number("123.23"),"<br />");
document.write(Number(false),"<br />");
document.write(Number(true),"<br />");
document.write(parseInt("58"), "<br />");
document.write(parseFloat("56.6"), "<br />");
//-------------------------输出结果---------------------------------
//强制转换
//false
//true
//false
//true
//6
//false
//10的二进制数为1010
//10的八进制数为12
//10的十进制数为10
//NaN
//123.23
//0
//1
//58
//56.6
</script>