This is a new technology, part of the ECMAScript 2015 (ES6) standard.
This technology's specification has been finalized, but check the compatibility table for usage and implementation status in various browsers.
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.
Description
Unlike most global objects, Reflect is not a constructor. You can not 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).
Methods
The Reflect object provides the following static functions which have the same names as the proxy handler methods. Some of these methods are the same as corresponding methods on Object.
Reflect.apply()- Calls a target function with arguments as specified by the
argsparameter. See alsoFunction.prototype.apply(). Reflect.construct()- The
newoperator as a function. Equivalent to callingnew target(...args). Reflect.defineProperty()- Similar to
Object.defineProperty(). Returns aBoolean. Reflect.deleteProperty()- The
deleteoperator as a function. Equivalent to callingdelete target[name]. Reflect.enumerate()- Like the
for...inloop. Returns an iterator with the enumerable own and inherited properties of the target object. Reflect.get()- A function that returns the value of properties.
Reflect.getOwnPropertyDescriptor()- Similar to
Object.getOwnPropertyDescriptor(). Returns a property descriptor of the given property if it exists on the object,undefinedotherwise. Reflect.getPrototypeOf()- Same as
Object.getPrototypeOf(). Reflect.has()- The
inoperator as function. Returns a boolean indicating whether an own or inherited property exists. Reflect.isExtensible()- Same as
Object.isExtensible(). Reflect.ownKeys()- Returns an array of strings with own (not inherited) property keys.
Reflect.preventExtensions()- Similar to
Object.preventExtensions(). Returns aBoolean. Reflect.set()- A function that assigns values to properties. Returns a
Booleanthat istrueif the update was successful. Reflect.setPrototypeOf()- A function that sets the prototype of an object.
Specifications
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) The definition of 'Reflect' in that specification. |
Standard | Initial definition. |
Browser compatibility
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Basic support | 44 | (Yes) | 42 (42) | Not supported | Not supported | Not supported |
| Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| Basic support | Not supported | Not supported | 42.0 (42) | Not supported | Not supported | Not supported |