undefined和null [英] undefined and null
问题描述
undefined === null => false
undefined == null => true
-
我已经考虑了<$ c的原因$ c> undefined == null 并且只发现一个案例:
I have thought about the reason of
undefined == null
and found out only one case:
if(document.getElementById() == null) ....
还有其他原因( undefined === null)== false
?
是否还有其他使用示例 ===
- 在javascript中操作?
Is there any other examples of use ===
- operation in javascript?
推荐答案
是否还有其他原因(undefined === null)== false?
Is there any other reason to make (undefined === null) == false ?
它们不相等,因此严格的等式比较算法认为它们是错误的。
They are not equal so the Strict Equality Comparison Algorithm considers them to be false.
是否还有其他使用示例=== - javascript操作?
Is there any other examples of use === - operation in javascript?
===
给出最可预测的结果。当我有类型强制的特定目的时,我只使用 ==
。 (参见抽象平等比较算法。)
The ===
gives the most predictable result. I only use ==
when I have a specific purpose for type coercion. (See Abstract Equality Comparison Algorithm.)
这篇关于undefined和null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!