setPrototypeOf vs obj.__proto__ assignment

Andrea Giammarchi andrea.giammarchi at gmail.com
Mon Apr 7 18:27:10 PDT 2014


just for topic and documentation sake ...

On Mon, Apr 7, 2014 at 11:02 AM, John Barton <johnjbarton at google.com> wrote:

>
> on platforms without setPrototypeOf(), it's advantages are not relevant.
> jjb
>
>

this works in Firefox since quite a while, and probably some other engine
that supports `__proto__` as non poisoned and configurable as every other
`Object.prototype` is:

```javascript
Object.setPrototypeOf || (
  Object.setPrototypeOf = function(set){
    delete Object.prototype.__proto__;
    return function setPrototypeOf(o, p) {
      set.call(o, p);
      return o;
    };
  }(
    Object.getOwnPropertyDescriptor(
      Object.prototype, '__proto__'
    ).set
  )
);
```

Best Regards
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140407/2abb6405/attachment.html>


More information about the es-discuss mailing list