When I do this:
Object.prototype.toString.call( null )
or t开发者_StackOverflow中文版his:
Object.prototype.toString.call( )
the browsers return the following string value (in both cases):
Chrome 9: [object global]
[object DOMWindow]
Firefox 3.6: [object Window]
Opera 11: [object Window]
However in IE9 RC the return values are [object Null]
and [object Undefined]
respectively.
The ES5 specification states:
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.
See here: http://es5.github.com/#x15.3.4.4
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. ;)
FYI, I just tested FF4, and it gives [object Null]
and [object Undefined]
精彩评论