4

您可以通过多种方式在 JavaScript 中创建对象:

// creates an object which makes the Object, prototype of data.
var data1 = new Object(); 

// Object literal notation; Object still is the prototype of data2.
var data2 = {}; 

// anotherObject is now the prototype of data3.
var data3 = Object.create(anotherObject); 

/* data3 is an object which can be verified bye typeof operator, 
   however, it now has no prototype and you can 
   build everything from scratch. */
var data3 = Object.create(null); 

但是不知道哪个版本的IE支持最后一种方法,即Object.create(null)方法?

4

1 回答 1

6

检查维基百科的JavaScript 版本历史。如果您找到 1.8.5 版本 - 这是您发现此对象工厂方法可用的语言版本 - Internet Explorer 的第 9 版是支持该版本的版本。

ECMAScript 5 兼容性表也包含此信息。

您也可以尝试使用 Microsoft 的 IE 虚拟机之一(可从此处获得,或者对于非常旧版本的 IE,Multiple IE

于 2011-08-11T09:55:35.393 回答