admin 管理员组文章数量: 1087134
It seems that the undefined is a property of window/global :
I always thought that undefined is, like null, a uniqe value in JavaScript.
But above code (tested in Chrome) make me confused.
Can some explain why
undefined in window
evalute to true, while
null in window
evaluate to false
It seems that the undefined is a property of window/global :
I always thought that undefined is, like null, a uniqe value in JavaScript.
But above code (tested in Chrome) make me confused.
Can some explain why
undefined in window
evalute to true, while
null in window
evaluate to false
Share Improve this question edited Apr 22, 2013 at 8:23 Henrik Andersson 47.3k16 gold badges100 silver badges94 bronze badges asked Apr 22, 2013 at 7:40 aztackaztack 4,6247 gold badges35 silver badges57 bronze badges 1- relevant: /questions/776950/javascript-undefined-undefined – John Dvorak Commented Apr 22, 2013 at 7:44
1 Answer
Reset to default 12Not only undefined
, but also Infinity
and NaN
are values of the global object
, in this case, window
(as of ES5.1 specification).
The fact you can't assign a value to undefined
is because the property is defined with the writable
attribute set to false
.
null
is a primitive value
(as is 5
) of the type Null
(as is Number
for 5
), not a property of window
.
Take a look at the annotated ES5 specification for more background on this, its quite readable!
本文标签: javascriptIs undefined a property of windowglobalStack Overflow
版权声明:本文标题:javascript - Is undefined a property of windowglobal? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744030643a2521436.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论