最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - From which version, IE can support Object.create(null)? - Stack Overflow

programmeradmin1浏览0评论

You can create an object in JavaScript in many ways:

// 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); 

But I don't know which versions of IE support the last method, i.e. Object.create(null) method?

You can create an object in JavaScript in many ways:

// 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); 

But I don't know which versions of IE support the last method, i.e. Object.create(null) method?

Share Improve this question edited Feb 1, 2013 at 12:08 hippietrail 17k21 gold badges109 silver badges179 bronze badges asked Aug 11, 2011 at 8:55 Saeed NeamatiSaeed Neamati 35.9k42 gold badges139 silver badges192 bronze badges 4
  • And what about of using inline object initializer {} or Object constructor new Object(), and don't lose your time with IE-specific behaviors? – Matías Fidemraizer Commented Aug 11, 2011 at 9:11
  • @Matias, I want to have an object with no prototype. You can't achieve that with {} or new Object(). – Saeed Neamati Commented Aug 11, 2011 at 9:26
  • You can't have an object without prototype in JavaScript, because the archetype of an object in this scripting language causally is the propotype! :D JavaScript isn't OOP, it's "prototype-oriented". – Matías Fidemraizer Commented Aug 11, 2011 at 9:30
  • @Matias, turns out that you can, and that's exactly what I want. To have null as the prototype of my object, or in other words, to have no prototype at all. – Saeed Neamati Commented Aug 11, 2011 at 9:45
Add a ment  | 

1 Answer 1

Reset to default 6

Check Wikipedia's JavaScript version history. If you find 1.8.5 version - and this is the language version where you find this Object factory method available - 9th version of Internet Explorer is the one supporting that.

The ECMAScript 5 Compatibility Table also has this information.

You can also try for yourself using one of Microsoft's IE virtual machines (available from here or, for very old versions of IE, Multiple IE.

发布评论

评论列表(0)

  1. 暂无评论