B.3.1 The __proto__ pseudo property

Allen Wirfs-Brock allen at wirfs-brock.com
Sun Apr 21 12:21:04 PDT 2013


On Apr 21, 2013, at 11:53 AM, Brendan Eich wrote:

> Allen Wirfs-Brock wrote:
>> ...
> 
>>> This is specified by ES5, already.
>> 
>> Doesn't matter because what ES5 specifies is already incompatible with web reality when the property name is  __proto__.
> 
> No. Browsers implementing ES5 and de-facto __proto__ use [[DefineOwnProperty]] per ES5 to make '__proto__' in 'var o = {__proto__: "haha"}' an own data property shadowing Object.prototype.__proto__.
> 
> Anything else (some variation on de-facto __proto__ that uses a magic per-object hidden [[DefineOwnProperty]], e.g.) breaks ES5.
> 

from FF 22 scratchpad:


var p = {__proto__: "silly"};
Object.getOwnPropertyDescriptor(p,"__proto__");
/*
undefined
*/
Object.getPrototypeOf(p)===Object.prototype
/*
true
*/
var p = {__proto__: "silly"};
Object.getOwnPropertyDescriptor(p,"__proto__");
/*
undefined
*/
Object.getPrototypeOf(p)===Object.prototype
/*
true
*/
var p = {__proto__: "silly"};
Object.getOwnPropertyDescriptor(p,"__proto__");
/*
undefined
*/
Object.getPrototypeOf(p)===Object.prototype
/*
true
*/
var p = {__proto__: "silly"};
Object.getOwnPropertyDescriptor(p,"__proto__");
/*
undefined
*/
Object.getPrototypeOf(p)===Object.prototype
/*
true
*/
var p = {__proto__: "silly"};
Object.getOwnPropertyDescriptor(p,"__proto__");
/*
undefined
*/
Object.getPrototypeOf(p)===Object.prototype
/*
true
*/
var p = {__proto__: "silly"};
Object.getOwnPropertyDescriptor(p,"__proto__");
/*
undefined
*/
Object.getPrototypeOf(p)===Object.prototype
/*
true
*/
var p = {__proto__: "silly"};var p = {__proto__: "silly"};
var p = {__proto__: "silly"};
Object.getOwnPropertyDescriptor(p,"__proto__");
/*
undefined
*/
Object.getPrototypeOf(p)===Object.prototype
/*
true
*/
p.__proto__ === Object.prototype
/*
true
*/

var r = {__proto__: p};
Object.getOwnPropertyDescriptor(r,"__proto__");
/*
undefined
*/
Object.getPrototypeOf(r)===Object.prototype
/*
false
*/


I don't see any shadowing or __proto__ going on here.

Allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130421/b08cbd18/attachment.html>


More information about the es-discuss mailing list