How to clean up __proto__ (was: Why we need to clean up __proto__)

Allen Wirfs-Brock allen at
Thu Dec 29 08:57:22 PST 2011

On Dec 29, 2011, at 3:38 AM, Lasse Reichstein wrote:

> There is one side-effect to defining __proto__ using a getter/setter
> property. You can extract the setter and store it for later, allowing
> you to change the prototype of objects after someone else deleted the
> __proto__ property.

Not if the built-in setter function for __proto__ is defined similarly to:

        {set: function __proto__(value) {
              if (Object.getPropertyDescriptor(this,'__proto__').set !== __proto__) throw new TypeError('invalid use of __proto__');
              ... //do the work of validating and setting [[Prototype]] of this

(and assuming that Object.getPropertyDescriptor is defined to access inherited properties)


More information about the es-discuss mailing list