国内最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2
您当前位置:首页 > web前端 > htmlcss > JavaScript中的==和===

JavaScript中的==和===

来源:程序员人生   发布时间:2015-08-19 08:17:23 阅读次数:3207次
console.log('[] == []是:'+([] == [])); //false console.log('[] === []是:'+([] === [])); //false console.log('{} == {}是:'+({} == {})); //false console.log('{} === {}是:'+({} === {})); //false //true console.log( '[] == !{}是:'+([] == !{} )); /*!{}是个布尔值,为false,因此我们比较的是 [] == 0*/ var n0 = 123; var n1 = new Number(123); var n2 = new Number(123); var n3 = Number(123); var n4 = Number(123); console.log('n0 == n1是:'+(n0 == n1)); //true console.log('n0 == n3是:'+(n0 == n3)); //true console.log('n0 === n1是:'+(n0 === n1)); //false console.log('n0 === n3是:'+(n0 === n3)); //true console.log('n1 == n2是:'+(n1 == n2)); //false console.log('n1 === n2是:'+(n1 === n2)); //false console.log('n1 == n3是:'+(n1 == n3)); //true console.log('n1 === n3是:'+(n1 === n3)); //false console.log('n3 == n4是:'+(n3 == n4)); //true console.log('n3 === n4是:'+(n3 === n4)); //true

输出截图:

compare_thumb.png

原文:http://www.ido321.com/1427.html

生活不易,码农辛苦
如果您觉得本网站对您的学习有所帮助,可以手机扫描二维码进行捐赠
程序员人生
------分隔线----------------------------
分享到:
------分隔线----------------------------
关闭
程序员人生