gpt4 book ai didi

javascript - null/undefined 在除 IE9 之外的所有浏览器中被替换为全局对象

转载 作者:搜寻专家 更新时间:2023-11-01 04:27:34 25 4
gpt4 key购买 nike

当我这样做时:

Object.prototype.toString.call( null )

或者这个:

Object.prototype.toString.call( )

浏览器返回以下字符串值(在两种情况下):

Chrome 9:[全局对象]
Safari 5:[object DOMWindow]
Firefox 3.6:[对象窗口]
Opera 11:[对象窗口]

但是在 IE9 RC 中,返回值分别是 [object Null][object Undefined]

ES5 规范指出:

NOTE The thisArg value is passed without modification as the this value. This is a change from Edition 3, where a undefined or null thisArg is replaced with the global object and ToObject is applied to all other values and that result is passed as the this value.

参见此处:http://es5.github.com/#x15.3.4.4

这是否意味着 IE9 是唯一遵循这一新引入规则的浏览器?

最佳答案

我要冒险说。 ;)

仅供引用,我刚刚测试了 FF4,它给出了 [object Null][object Undefined]

关于javascript - null/undefined 在除 IE9 之外的所有浏览器中被替换为全局对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5055061/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com