js自动类型转换

<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>

posted @ 2016-08-10 17:06  _即炤  阅读(302)  评论(0编辑  收藏  举报