为什么 isFinite(undefined) != isFinite(null)? [英] Why is isFinite(undefined) != isFinite(null)?

查看:63
本文介绍了为什么 isFinite(undefined) != isFinite(null)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么在 JavaScript 中 undefined 的值被认为是有限的,而 null 不是?

Why is the value for undefined considered Finite in javascript while null is not?

这是一个非常基本的问题,它阻碍了我的 googlefoo(噪音太大).

This is a very basic question, which has thwarted my googlefoo (too much noise).

isFinite(undefined); // false
isFinite(null); // true

我不明白,因为我希望以相同的方式处理 null 和 undefined.

I do not understand as I would expect null and undefined to be handled in the same manner.

推荐答案

这是因为 Number(null) === 0.

http://es5.github.io/#x9.3

这篇关于为什么 isFinite(undefined) != isFinite(null)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆