以下是对我有意义的例子。为什么`isFinite(null)=== true`?
isFinite(5) // true - makes sense to me, it is a number and it is finite
typeof 5 // "number"
isFinite(Infinity) // false - makes sense for logical reasons
typeof Infinity // "number"
isFinite(document) // false - makes sense as well, it's not even a number
typeof document // "object"
以下是我感到困惑的地方。
isFinite(null) // true - Wait what? Other non-number objects returned false. I see no reason?
typeof null // "object"
我只是没有看到背后的推理。 我想要的是最低级别的答案。 我认为null
正在转换为0,为什么?这有什么其他影响?
可能的重复[为什么isFinite(undefined)!= isFinite(null)?](http://stackoverflow.com/questions/19254205/why-is-isfiniteundefined-isfinitenull) – adeneo
低级响应:在数学(因此在JavaScript中表面上),当某些值为空值时,它有一个空值或零值。零是有限数字。因此,null是有限的。除非你能成为第一个找到无穷的倒数的人,否则我怀疑这会永远改变。 – TylerH
@TylerH这是一个很好的方式来说出它。谢谢。 – user1596138