gpt4 book ai didi

javascript - 未定义和空

转载 作者:可可西里 更新时间:2023-11-01 02:54:19 26 4
gpt4 key购买 nike

undefined === null => false
undefined == null => true
  1. 我想过undefined == null的原因,发现只有一种情况:

    if(document.getElementById() == null) ....

    是否还有其他原因使 (undefined === null) == false

  2. 是否还有其他使用 === 的例子 - 在 javascript 中操作?

最佳答案

Is there any other reason to make (undefined === null) == false ?

它们不相等,所以 Strict Equality Comparison Algorithm认为它们是错误的。

Is there any other examples of use === - operation in javascript?

=== 给出了最可预测的结果。当我有特定的类型强制目的时,我只使用 == 。 (参见 Abstract Equality Comparison Algorithm。)

关于javascript - 未定义和空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6031372/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com