空/未定义与全局对象除了IE9浏览器的所有更换 [英] null/undefined are replaced with the global object in all browsers except IE9

查看:135
本文介绍了空/未定义与全局对象除了IE9浏览器的所有更换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我这样做:

Object.prototype.toString.call( null )

或本

Object.prototype.toString.call( )

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

the browsers return the following string value (in both cases):

镀铬9: [反对全球] 结果
Safari 5的: [对象DOMWindow] 结果
火狐3.​​6: [对象窗口] 结果
歌剧11: [对象窗口]

Chrome 9: [object global]
Safari 5: [object DOMWindow]
Firefox 3.6: [object Window]
Opera 11: [object Window]

然而,在IE9 RC的返回值 [对象空] [对象未定义] 分别。

However in IE9 RC the return values are [object Null] and [object Undefined] respectively.

在ES5规范状态:

注thisArg值传递
  不加修饰的本
  值。这是一版变化
  3,凡未定义或为空thisArg
  被替换全局对象和
  ToObject被施加到所有其它
  价值观和结果作为传递
  在此值。

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是遵循这个新推出的规则唯一的浏览器?

Does this mean that IE9 is the only browser that follows this newly introduced rule?

推荐答案

我要出门的肢体和说的的。 ;)

I'm going to go out on a limb and say yes. ;)

仅供参考,我只是测试FF4,它给 [对象空] [对象未定义]

FYI, I just tested FF4, and it gives [object Null] and [object Undefined]

这篇关于空/未定义与全局对象除了IE9浏览器的所有更换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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