JavaScripture
Contribute via GitHub Feedback

JavaScript ProxyHandler : Object

The ProxyHandler is used by Proxy to intercept and modify the behavior of the proxied object. You may use any JavaScript object as a ProxyHandler. If any of the following methods are not provided, the Proxy will use the default behavior for that method.

Instance Methods

apply(target : Function, thisArg : Object, parameters : Array) : Object

Called when proxy(...), proxy.apply(thisArg, parameters), or proxy.call(thisArg, ...parameters) are called.

Example:

Run

Results:

 

construct(target : Function, parameters : Array) : Object

Called when new target(...parameters) is called.

Example:

Run

Results:

 

defineProperty(target : Object, name : String, propertyDescriptor : PropertyDescriptor) : undefined

Called when Object.defineProperty() is called on the proxy.

Example:

Run

Results:

 

deleteProperty(target : Object, name : String) : Boolean

Called when delete proxy[name] is called. Return true if the delete was successful.

Example:

Run

Results:

 

enumerate(target : Object) : Array<String>

get(target : Object, name : String, proxy : Proxy) : Object

Called when reading the name property of the target of the proxy. The return value is used as the value of the property.

Example:

Run

Results:

 

getOwnPropertyDescriptor(target : Object, name : String) : PropertyDescriptor

Called when Object.getOwnPropertyDescriptor() is called on the Proxy.

Example:

Run

Results:

 

has(target : Object, name : String) : Boolean

Called when name in proxy is called.

Example:

Run

Results:

 

isExtensible(target : Object) : Boolean

Called when checking to see if an Object is extensible.

Example:

Run

Results:

 

ownKeys(target : Object) : Array<String>

Called when Object.keys(), Object.getOwnPropertyNames(), or Object.getOwnPropertySymbols() are called on the proxy.

Example:

Run

Results:

 

preventExtensions(target : Object) : Boolean

Called when Object.preventExtensions() is called on the Proxy. Return true if preventExtensions succeeded.

Example:

Run

Results:

 

set(target : Object, name : String, value : Object, proxy : Proxy) : Object

Called when setting the name property of the target of the proxy.

Example:

Run

Results: