开发者

Javascript: Which Browsers support prototype inheritance?

开发者 https://www.devze.com 2023-03-13 03:39 出处:网络
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 suppor开发者_高级运维ted in IE 7 and down below, but I can\'t find that

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 suppor开发者_高级运维ted 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.


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

精彩评论

暂无评论...
验证码 换一张
取 消