-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2021/01/28 - null是对象吗?为什么 #32
Labels
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
null
的概念null
是一种原始类型,且这种类型的唯一值只有null
,当null
作为值存在时,用于表示对象的值未设置,或者说把它当成一个还没有创建的对象null
和undefined
的区别一般情况而言,两者没有区别,在布尔运算中都会认为是
Falsy
,但在Ecma262标准中,两者的定义有着一些差别,标准定义中undefined
作为值时,表示未给变量赋值时的原始值,而null
在作为值时,表示的是有意缺少任何对象值的原始值,所以两者的区别可以认为是:null
表示是一个没有创建的对象,这也能在标准定义上勉强解释为什么typeof null == 'object'
undefined
表示一个变量缺少了值,即未给变量赋值时的原始值The text was updated successfully, but these errors were encountered: