本文介绍了NaN是假的吗?为什么NaN === false返回false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 为什么 NaN === false => false,是不是NaN falsy?

  2. 为什么 NaN === NaN => false,但是 !! NaN === !! NaN => true

  1. Why NaN === false => false, isn't NaN falsy?
  2. Why NaN === NaN => false, but !!NaN === !!NaN => true

我一直绞尽脑汁试图解决这个问题。

I've been racking my brain trying to figure this out.

推荐答案


  1. Falsy 并严格等于 false 是非常不同的东西,这就是为什么一个人有 y 而不是 e 。 ;)

  2. NaN 规格永远不会等于任何东西。问题的第二部分是比较 false === false ,这很有趣, true :)

  1. Falsy and being strictly equal to false are very different things, that's why one has a y instead of an e. ;)
  2. NaN is spec'd to never be equal to anything. The second part of your question is comparing false === false, which is funnily enough, true :)

这篇关于NaN是假的吗?为什么NaN === false返回false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-28 00:25