__proto__ and accessor descriptors

David Bruant bruant.d at gmail.com
Fri Oct 26 14:30:21 PDT 2012

Le 26/10/2012 22:56, Asen Bozhilov a écrit :
> I would like to define custom getter and setter for `__proto__`
> property: 
> var obj = Object.defineProperty({}, '__proto__', {
>     get : function () {return '__proto__ getter'},
>     set : function (){return '__proto__ setter'}
> });
> console.log(obj.__proto__); //[object Object]
> console.log(obj.__proto__ = {}); //[object Object]
> I didn't find an engine which outputs the values in get and set.
On Firefox Aurora, I find:
"__proto__ getter"
"[object Object]"

> The idea behind my code is to reject the `__proto__` ability to change
> the internal [[Prototype]]
In conforming engines, 'delete Object.prototype.__proto__' will do the
job for all objects at the same time.

> Is the above behavior should be observed according ECMAScript 6? 
It is not, but it's likely that no implementation perfectly conforms.
Take a look at
According to this strawman, the output should indeed be
"__proto__getter" then "__proto__setter".


More information about the es-discuss mailing list