2014-05-05 19:40 GMT+02:00 John Barton <[email protected]>: > I'm hoping someone can explain this result which surprises me. > > If I create an object with a Proxy-ed prototype, the resulting object does > not obey .__proto__ equal Object.getPrototypeOf(). >
There's no such equivalence, even for regular objects. `__proto__` is just a property name, so `proxy.__proto__` just triggers the "get" trap, as any normal property access. If the proxy should treat it specially, you need to special-case the name `__proto__` in the "get" trap. However, as Allen points out, forwarding should work correctly as long as you also forward the "receiver" binding using the Reflect.get method. > At this point, I expected > hasProxyAsProto.__proto__ === aProxy > but it it not true. Moreover, the operation > hasProxyAsProto.__proto__ > calls the Proxy handler get function with name === '__proto__': that makes > no sense as hasProxyAsProto is not a Proxy. > If an object inherits from a proxy, then any property access for a non-own property will traverse the prototype chain. If it hits a proxy, that proxy's "get" trap is called. Cheers, Tom
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

