复盘修正错误01
js刷题后进行的自我检查,如果有错欢迎纠正~~
先感谢啦。
alert(NaN == unfined);
//false
==用来比较值,而NaN的值不确定,unfined的值是0,所以他们的大小不相等。
alert(NaN == NaN);
//false
NaN的值不确定,所以不能用来比较大小。
var str = "123abc";
alert(typeof str++);
alert(str);
//number
//NaN
关于str++
起初理所应当地认为str++就是str = str +1;
即 str= “123abc”+ 1;得到“123abc1”字符串。
并没有意识到在n++中会进行隐式转换,str被转换成number类型。进行算术运算后不能得到正常数字(123abc),则返回NaN。
console.log(undefined==0)
//false
同样是忽视了隐式转换,没有意识到undefined本质是NaN,NaN和0当然不相等!
console.log(null==undefined)
//true
比较相等性之前,不能将 null 和 undefined 转换成其他任何值,并且规定null 和 undefined 是相等的。
null 和 undefined都代表着无效的值。
console.log(null !== undefined);
//true
!= 是不相等,!==是不全等。
null是object,undefined是NaN。
console.log(null == 0);
//false
规定里,在==情况里,null不会被转变成其他任何值,所以null=0是false。
653

被折叠的 条评论
为什么被折叠?



