gpt4 book ai didi

javascript - 与 Javascript 中的 NaN 比较

转载 作者:行者123 更新时间:2023-11-30 06:56:52 24 4
gpt4 key购买 nike

我遇到了这个奇怪的问题。

enter image description here

为什么会这样?!应该这样吗?

最佳答案

来自MDN docs for isNaN :

Unlike all other possible values in JavaScript, it is not possible to rely on the equality operators (== and ===) to determine whether a value is NaN or not, because both NaN == NaN and NaN === NaN evaluate to false. Hence, the necessity of an isNaN function.

使用isNaN相反。

关于javascript - 与 Javascript 中的 NaN 比较,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10788128/

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