window.toString.call is undefined in IE8

前端 未结 2 1608
独厮守ぢ
独厮守ぢ 2021-01-18 03:38

When you run:

window.toString.call(\"\")

everything\'s fine in FF/CH but in IE8 you get a script error. Investigating a bit more it turned

2条回答
  •  没有蜡笔的小新
    2021-01-18 04:08

    window is a host object, and the ECMAScript Language Specification (3rd edition) does not require host objects to be derived from the native Object object. In IE (and probably in some other browsers) host objects aren't, so they don't support any of the native methods or properties (although they may have methods or properties with the same names as native methods or properties which are accessible to scripts).

    If all you want is to get hold of the language implementation's default native toString method then you should use Object.prototype.toString.call("").

提交回复
热议问题