标签:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>数据类型转换</title> <script type="text/javascript"> var str1 = "123.09abc", str2 = "abc123.09"; var num; // num = parseInt(str1); // num = parseFloat(str1); // num = parseFloat(str1); // num = str1.toString(); // num = parseInt(str2); // num = parseFloat(str2); // num = str2.toString(); // num = Boolean(str1); // num = Number(str1); // num = String(str1); document.write( num +"<br/>类型为:"+ typeof num ); </script> </head> <body> </body> </html>
标签:
原文地址:http://www.cnblogs.com/xiaotaoxu/p/5544556.html