Proxy usage mode

var proxy = new Proxy(target, handler);

The target parameter corresponds to the instance of the object you want to intercept, and handler is a configuration object. Object to specify which operations on the target object you want to intercept.

There are 13 types of interception operations

get(target, propkey, receiver)

Used to intercept reads of object properties, such as proxy.foo and proxy[‘foo’].

set(target, propkey, value, [receiver])

Intercepting object property Settings, such as proxy.foo = v or proxy[‘foo’] = v, returns a Boolean value.

has(target, propkey)

Intercepts the propKey in proxy operation, returning a Boolean value

**deleteProperty(target, propKey)

Intercepts the delete Proxy [propKey] operation, returning a Boolean value

**ownKeys(target)

Interception Object. GetOwnPropertyNames (proxy), Object. GetOwnPropertySymbol (proxy), the Object. The keys (proxy),

for… In returns an array. This method returns the property names of all of the target Object’s own properties, while object.keys () returns only

The traversable properties of the target object itself.

getOwnPropertyDescriptor(target,propKey)

Interception Object. GetOwnPropertyDescriptor (target, propKey), returns the attributes describe objects.

**defineProperty(target, propKey, propDesc)

Intercepts Object.defineProperty(target, propKey, propDesc), Object.defineProperties(proxy, propDescs) and returns a Boolean value

preventExtensions(target)

Intercepting Object.preventExtensions(proxy) returns a Boolean value.

getPrototypeOf(target)

Intercepts Object.getProtoTypeof (proxy) to return an Object.

isExtensible(target)

Intercepting Object.isextensible (proxy), returning a Boolean value.

setPrototypeOf(target, proto)

Intercepts Object.setProtoTypeof (proxy, proto), returning a Boolean value. If the target object is a function, there are two additional operations that can be intercepted.

apply(target, object, args)

Intercepting operations called by Proxy instances as functions, such as Proxy (… The args), proxy. Call (object,… The args), proxy. Apply (…). .

construct(target, args)

Intercepting operations called by Proxy instances as constructors, such as new Proxy (… The args).