A target base .Reflect
Reflect the object is occurring ES6 new API, a method for the inside of the operation target.
Features:
1. For the operation there is a clear return results. As the operation returns a Boolean value indicating success or not
2. Proxy interception and one to one method to achieve operating default behavior
3. in, delete, new commands, use the method to achieve
4. The method of this object will gradually replace the method of the Object
II. Static methods
Proxy method of correspondence and interception, a total of 13 methods;
The first argument of all methods must be the object. Otherwise error.
Returns a Boolean value methods are:
1. Reflect.set(target,propKey, value, receiver)
target [propKey] = value; / / if the operation is successful
If you pass receiver, the receiver this point
2. Reflect.has(target, propKey)
propKey in target
3. Reflect.deleteProperty(target, propKey)
the Delete target [propKey] // whether the operation was successful
4. Reflect.setPrototypeOf(target, proto)
.__ = proto proto__ target; / / if the operation is successful
5. Reflect.defineProperty(target, propKey, propDescriotor)
Object.defineProperty (target, propKey, propDescriptor) // if the operation is successful
6. Reflect.isExtensible(target)
Object.isExtensible(target)
7.Reflect.preventExtensions(target)
Object.preventExtensions (target) // return operation is successful
Return non-Boolean value methods are:
1. Reflect.get(target, propKey,receiver)
target[propKey]
1. If the method parameters passed in the receiver, then, if there is this getter method, this point receiver
2. If not, return undefined
2. Reflect.construct(Target, args)
new Target(...args)
3. Reflect.getPrototypeOf(target)
target.__proto__
4. Reflect.apply(fn, thisArg, args)
Function.prototype.apply.call(target, thisArg, args);
5. Reflect.getOwnPropertyDescriptor(target, propKey)
Object.getOwnPropertyDescriptor(target, propKey)
6.Reflect.ownKeys(target)
Object.getOwnPropertyNames(target) +
Object.getOwnPropertySymbols(target)