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

Tom Van Cutsem tomvc.be at gmail.com
Sat Jan 19 02:08:06 PST 2013


2013/1/18 Claus Reinke <claus.reinke at talk21.com>

> 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
>

Yep, this is true. But it doesn't violate any invariants since we could
have made y.foo return 99 as well, if we had used Object.defineProperty to
shadow 'foo'.

Cheers,
Tom
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130119/9bea6e8a/attachment.html>


More information about the es-discuss mailing list