proxy awareness

  Proxy for modifying the default behavior of some operations may be understood to be assumed that the target object before layer interception or encapsulation of native Object methods; by the Proxy setting, all access outside through this must intercepting layer, and therefore can be filtered and modified by the external access.

  Proxy support of Operation intercepted a total of 13:

    1), get (target, propKey, receiver): knockdown amount read object properties, such proxy.foo or proxy [ 'foo'];

    2), set (target, propKey, value, receiver): setting an object intercepting properties, such proxy.foo = 1, returns a Boolean value;

    3), has (target, propKey): the proxy intercepting propKey in operation, returns a Boolean value;

    4), deleteProperty (target, propKey): intercepting delete proxy [propKey] operation, returns a Boolean value;

    5), ownKeys (target): interception Object.getOwnPropertyName (proxy), Object.getOwnPropertySymbols (proxy), Object.keys (proxy), for ... in loop returns an array; the method returns all audiences own properties attribute names, and Object.keys () returns only the result of including the target object itself may traverse attributes;

    6), getOwnPropertyDescriptor (target, propKey): interception Object.getOwnPropertyDescriptor (proxy, propKey), Returning to the description of object properties;

    7), defineProperty (target, propKey, propDesc): interception Object.defineProperty (proxy, propKey, propDesc), Object.defineProperties (proxy, propDescs), returns a Boolean value;

    8), preventExtensions (target): interception Object.preventExtensions (proxy), returns a Boolean value;

    9), isExtensible (target): interception Object.isExtensible (proxy), returns a Boolean value;

    10), setPrototypeOf (target, proto): interception Object.setPrototyOf (proxy, proto), returns a Boolean value; if the target object is a function, then there are two additional operations can intercept;

    11), getPrototypeOf (target): interception Object.getPrototypeOf (proxy), returns a Boolean value;

    12), apply (target, object, args): Proxy instance as intercepting a function call, such as proxy (... args), proxy.call (object, ... args), proxy.apply (...) ;

    13), construct (target, args): interception proxy examples of the constructor call, such as new Proxy (... args);

  

Guess you like

Origin www.cnblogs.com/mufc/p/11345429.html