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

Javascript: Which Browsers support prototype inheritance? - Stack Overflow

programmeradmin2浏览0评论

Currently I'm not using prototype because I remember that a day I've read an article where it was stated that Prototype is not supported in IE 7 and down below, but I can't find that article again but by the way it would be good to know how it is supported overall.

Currently I'm not using prototype because I remember that a day I've read an article where it was stated that Prototype is not supported in IE 7 and down below, but I can't find that article again but by the way it would be good to know how it is supported overall.

Share Improve this question edited Dec 28, 2011 at 22:11 Tom van der Woerdt 30k7 gold badges74 silver badges105 bronze badges asked Jun 13, 2011 at 15:44 Adam HalaszAdam Halasz 58.3k67 gold badges153 silver badges216 bronze badges 2
  • I updated your title and edit to better reflect what you are asking. – John Conde Commented Jun 13, 2011 at 15:55
  • thanks! I think it's a shame that a Javascript library named itself into a very important part of Javascript. It's really confusing, why don't they call themself Javascript Variables to confuse everyone... And I wonder if the people who uses prototype.js knows what is prototype in javascript :) – Adam Halasz Commented Jun 13, 2011 at 15:57
Add a comment  | 

5 Answers 5

Reset to default 11

JScript (Microsoft's interpretation of Javascript) has supported the prototype property since version 2.0 (MSDN). The first version of Internet Explorer that supported JScript 2.0 was IE 3 (MSDN).

I'd say you're safe with IE7!


Edit: perhaps you're thinking about modifying the prototypes of host objects, such as Node. This is indeed not supported by IE >=7, and is a bad idea anyway. A good article on this is at perfectionkills.com.

The attribute .prototype exists in all JS implementations, otherwise it wouldn't be Javascript. ECMA-262 December 1999:

Objects

ECMAScript does not contain proper classes such as those in C++, Smalltalk, or Java, but rather, supports constructors which create objects by executing code that allocates storage for the objects and initialises all or part of them by assigning initial values to their properties. All constructors are objects, but not all objects are constructors. Each constructor has a Prototype property that is used to implement prototype-based inheritance and shared properties. Objects are created by using constructors in new expressions; for example, new String("A String") creates a new String object. Invoking a constructor without using new has consequences that depend on the constructor. For example, String("A String") produces a primitive string, not an object.

According to their downloads page, the current version of Prototype (1.7) is compatible with the following browsers:

Browser         Version(s)
Mozilla Firefox ≥ 1.5
Microsoft Internet Explorer for Windows ≥ 6.0
Apple Safari    ≥ 2.0.4
Google Chrome   ≥ 1.0
Opera           ≥ 9.25

update

IE7 definitely supports prototype inheritance.

If you mean the Prototype library, then Prototype's download page states that it is compatible with IE6 and higher.

[EDIT]

Your question edit makes the question very confusing. When you say "the real Javascript Prototype", what do you mean? Do you mean the feature of Javascript which allows you to add methods and properties to classes (eg String.Prototype.trim = function() {...}) then yes, this is a basic property of the language, and has existed since the very begining, so yes it would be supported in IE7.

According to the Prototype website, it's compatible with IE6+, and a whole host of other browsers. However, I rarely use it so I can't talk from experience.

发布评论

评论列表(0)

  1. 暂无评论