Javascript 为什么不';有些对象在IE中没有构造函数吗?

Javascript 为什么不';有些对象在IE中没有构造函数吗?,javascript,internet-explorer,dom,object,constructor,Javascript,Internet Explorer,Dom,Object,Constructor,下面的JavaScript代码在不同的浏览器中具有不同的效果: document.write(this.location.constructor); document.write("<br/>"); document.write(this.constructor); document.write("<br/>"); 在Firefox中,该页面具有: function Location() { [native code] } function DOMWindow() {

下面的JavaScript代码在不同的浏览器中具有不同的效果:

document.write(this.location.constructor);
document.write("<br/>");
document.write(this.constructor);
document.write("<br/>");
在Firefox中,该页面具有:

function Location() { [native code] }
function DOMWindow() { [native code] }
[object Location]
[object Window]
undefined
undefined
在IE8中,该页面具有:

function Location() { [native code] }
function DOMWindow() { [native code] }
[object Location]
[object Window]
undefined
undefined

Chrome和Firefox之间的差异可能是不同的
toString()
实现。我无法理解为什么这两个对象的构造函数在IE中是未定义的。如果它们的构造函数是未定义的,那么它们的原型呢?它们也是未定义的吗?

使用IE8调试控制台,我使用您给出的代码作为示例没有问题

我的结果

[object Location]
[object Window]

您确定没有其他原因导致这些失败吗?

使用IE8调试控制台,以您给出的代码为例,我没有任何问题

我的结果

[object Location]
[object Window]

您确定没有其他原因导致这些失败吗?

我正在使用IE 8.0.6001.18372。有趣的是,如果我加载一个带有“document.write(this.constructor)”的本地html,它是未定义的;如果我只是在URL输入栏中键入“javascript:this.constructor”,它会显示[object Window]。我使用的是IE 8.0.6001.18372。有趣的是,如果我加载一个带有“document.write(this.constructor)”的本地html,它是未定义的;如果我只是在URL输入栏中键入“javascript:this.constructor”,它会显示[object Window]。