码迷,mamicode.com
首页 > Web开发 > 详细

js自动类型转换

时间:2016-08-10 17:33:57      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:

<script>

testeq0 = null == undefined;

testeq1 = "0" == 0; //比较前字符串转换为数字

testeq2 = 0 == false; //比较前布尔值转换成数组

testeq3 = "0" ==false; //比较前,字符串和布尔值都转换成了数组

testeq4 = NaN == undefined; //false

//alert(testeq4);

?

x + ""; //等价于String(x)

+x; //等价于Number(x)

x-0; //同上

!!x; //双叹号,等价于Boolean(x)

</script>

js自动类型转换

标签:

原文地址:http://www.cnblogs.com/helkbore/p/5757512.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!