16

What web browsers use the __proto__? Mozilla states that:

Note that __proto__ may not be available in JavaScript versions other than that in Mozilla.

Alex Wayne
  • 178,991
  • 47
  • 309
  • 337
Tower
  • 98,741
  • 129
  • 357
  • 507

4 Answers4

8

Click here for your answer.

Details

The most general way would be to test this page in different browsers:

<html>
  <head>
    <script type="text/javascript">
      function a() {}
      if ( (new a).__proto__ === a.prototype )
          alert('supported');
    </script>

  </head>
</html>

It alerts if a browser supports __proto__. I've submitted it to browsershots.org, which will create screenshots of the page in many different browsers. Thus, you should see--by means of the alert message--which browser does support it.

wnrph
  • 3,293
  • 4
  • 26
  • 38
7

The Browser Security Handbook has a table showing which browsers expose __proto__.

Currently, those browsers are:

  • Firefox 2
  • Firefox 3
  • Safari
  • Chrome
  • Android

Those excluded:

  • IE 6, 7, 8
  • Opera
strager
  • 88,763
  • 26
  • 134
  • 176
3

The end of the sentence you posted is See below for workarounds., where there is a discussion on an alternative method extends() that uses super.prototype:

function extend(child, super){  
  for (var property in super.prototype) {  
    if (typeof child.prototype[property] == "undefined")  
      child.prototype[property] = super.prototype[property];  
  }  
  return child;  
}
Oded
  • 489,969
  • 99
  • 883
  • 1,009
  • I know, but I want to know what web browsers are supporting `__proto__`. Depending on the answer, I may not even need that kind of functionality. – Tower Jun 21 '10 at 07:40
  • 2
    I don't understand why you'd copy properties from one object into another... This defeats the purpose of the powerful prototypal inheritance built into JS. – Marius Apr 21 '14 at 19:38
0

This is not direct answer to the question but it may help for those who wanna know the prototype of the object instance (this is for what __proto__ is often used). All modern browsers (including IE9) supports getPrototypeOf() which can be used to determine the object's prototype. The irony of fate is that some still actual browsers like IE7 and IE8 that don't support Object.getPrototypeOf(obj) don't support obj.__proto__ as well. For those browsers you can use obj.constructor.prototype. However it is a bit dangerous because this property can be redefined.

Konstantin Smolyanin
  • 17,579
  • 12
  • 56
  • 56