Proxy target as __proto__? (Re: Proxy's optional target)

Claus Reinke claus.reinke at talk21.com
Fri Jan 18 14:39:06 PST 2013


Hi Tom,

> I'm not sure I fully understand your proposal, but could you not achieve it
> by simply doing:
> 
> var target = ...; // might be frozen
> var p = Proxy( Object.create(target), handler);

Ah, too obvious for me, thanks! 

Also, proxy wrappers often modify functions, which tend to be on 
a non-frozen prototype. So perhaps it isn't as big an issue as I thought.

Claus

PS. I probably shouldn't mention that Proxies' invariant checks
    only against own properties behave differently from how non
    Proxy objects behave, if a target prototype property happens 
    to be frozen (override prohibition non-mistake)?

var x = Object.freeze({foo: 88});
var y = Object.create(x);

y.foo = 99; // fail
console.log( y.foo ); // 88

var yp = Proxy(y,{get:function(t,n,r){ return n==="foo" ? 99 : t[n] } });
console.log( yp.foo ); // 99
 


More information about the es-discuss mailing list