undefined和null [英] undefined and null

查看:90
本文介绍了undefined和null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

undefined === null => false
undefined == null => true




  1. 我已经考虑了<$ c的原因$ c> undefined == null 并且只发现一个案例:

  1. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆