A proxy object is an exotic object whose essential internal methods are partially implemented using ECMAScript code. Every proxy object has an internal slot called [[ProxyHandler]]. The value of [[ProxyHandler]] is an object, called the proxy's handler object, or null. Every proxy object also has an internal slot called [[ProxyTarget]] whose value is either an object or the null value. This object is called the proxy's target object.
When a handler method is called to provide the implementation of a proxy object internal method, the handler method is passed the proxy's target object as a parameter. Invoking an internal method on the proxy results in the invocation of the corresponding internal method on the proxy's target object if the handler object does not have a method corresponding to the internal trap.
[[GetPrototypeOf]] ( )
- Let trap be ? GetMethod(handler, "getPrototypeOf").
- If not IsExtensible(target) or trap is undefined, Return ? target.[[GetPrototypeOf]]().
- return call trap on target to get target's prototype
[[SetPrototypeOf]] ( V )
- if not IsExtensible(target), return true
- Let trap be ? GetMethod(handler, "setPrototypeOf").
- If trap is undefined, Return ? target.[[SetPrototypeOf]](V).
- return call trap on target&V to set target's prototype
No comments:
Post a Comment