NaN评估背后的逻辑是什么?(What logic is behind NaN evaluation? [duplicate])

编程入门 行业动态 更新时间:2024-10-26 05:20:17
NaN评估背后的逻辑是什么?(What logic is behind NaN evaluation? [duplicate])

这个问题在这里已有答案:

为什么NaN === NaN是假的? [重复] 3个答案

你能解释一下NaN中NaN的逻辑评估吗?

NaN==NaN (false) !NaN==!NaN (true) NaN!=NaN (true) NaN==false (false) NaN==true (false)

我在这里有点惊讶......

This question already has an answer here:

Why is NaN === NaN false? [duplicate] 3 answers

Can you explain the logical evaluation of NaN in javascript?

NaN==NaN (false) !NaN==!NaN (true) NaN!=NaN (true) NaN==false (false) NaN==true (false)

I am a little surprised here...

最满意答案

因为这就是规范所说的。

具体来说,IEE浮点规范说NaN不等于自己。 因此,在Javascript中,没有NaN可以相等的值。

!NaN是true ,因为NaN是一个假值。

这使您的所有示例都显而易见。

Because that's what the spec says.

Specifically, the IEE floating point spec says that NaN does not equal itself. Therefore, in Javascript, there is no value that NaN can ever equal.

!NaN is true, because NaN is a falsy value.

This makes all of your examples obvious.

更多推荐

本文发布于:2023-08-03 14:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1390577.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:逻辑   NaN   logic   duplicate   evaluation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!