更新时间:2023-12-03 23:14:40
来自 isNaN
的MDN文档:
From the MDN docs for isNaN
:
与JavaScript中所有其他可能的值不同,不可能 依靠相等运算符(==和===)来确定是否 值是否为NaN,因为NaN == NaN和NaN === NaN都会求值 虚假.因此,必须要有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
.