时间:2021-08-28 09:26:46 | 栏目:JavaScript代码 | 点击:次
1、string-->number
string类型 *1 即可变成 number类型
2、number-->string
number类型 +'‘ 即可变成 string 类型
<script type="text/javascript"> function screenInfo() { var str = '012.8372'; var s = 0; str = str * 1; alert(typeof (str));//number s += ''; alert(typeof (s));//string var boo = true; alert(typeof(boo));//boolean var bs = Boolean(s); alert("bs:" + typeof (bs));//boolean alert("bsv:" + bs);//true } </script>