ECMAScript 6 Meta Reflect&Proxy
ECMAScript 6 Meta Reflect&Proxy
Reflect
Reflect is a built-in object that provides methods for interceptable JavaScript operations. The methods are the same as those of proxy handlers. Reflect
is not a function object, so it's not constructible.
Unlike most global objects, Reflect is not a constructor. You cannot use it with a new operator or invoke the Reflect object as a function. All properties and methods of Reflect are static (just like the Math object).
Reflect.apply()
Calls a target function with arguments as specified by the args parameter. See also
Function.prototype.apply()
.
Reflect.construct()
The new operator as a function. Equivalent to calling new target(...args). Provides also the optional possibility to specify a different prototype.
Reflect.get()
A function that returns the value of properties.
Proxy
The Proxy
object is used to define custom behavior for fundamental operations (e.g. property lookup, assignment, enumeration, function invocation, etc).
var p = new Proxy(target, handler);
target - A target object to wrap with Proxy. It can be any sort of object, including a native array, a function or even another proxy.
handler - An object whose properties are functions which define the behavior of the proxy when an operation is performed on it.
Methonds
handler.getPrototypeOf()