{{JSRef}}
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 {{jsxref("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 {{jsxref("Object")}}.
- {{jsxref("Reflect.apply()")}}
- Calls a target function with arguments as specified by the
args
parameter. See also {{jsxref("Function.prototype.apply()")}}. - {{jsxref("Reflect.construct()")}}
- The
new
operator as a function. Equivalent to callingnew target(...args)
. - {{jsxref("Reflect.defineProperty()")}}
- Similar to {{jsxref("Object.defineProperty()")}}. Returns a {{jsxref("Boolean")}}.
- {{jsxref("Reflect.deleteProperty()")}}
- The
delete
operator as a function. Equivalent to callingdelete target[name]
. - {{jsxref("Reflect.enumerate()")}}
- Like the
for...in
loop. Returns an iterator with the enumerable own and inherited properties of the target object. - {{jsxref("Reflect.get()")}}
- A function that returns the value of properties.
- {{jsxref("Reflect.getOwnPropertyDescriptor()")}}
- Similar to {{jsxref("Object.getOwnPropertyDescriptor()")}}. Returns a property descriptor of the given property if it exists on the object, {{jsxref("undefined")}} otherwise.
- {{jsxref("Reflect.getPrototypeOf()")}}
- Same as {{jsxref("Object.getPrototypeOf()")}}.
- {{jsxref("Reflect.has()")}}
- The
in
operator as function. Returns a boolean indicating whether an own or inherited property exists. - {{jsxref("Reflect.isExtensible()")}}
- Same as {{jsxref("Object.isExtensible()")}}.
- {{jsxref("Reflect.ownKeys()")}}
- Returns an array of the target object's own (not inherited) property keys.
- {{jsxref("Reflect.preventExtensions()")}}
- Similar to {{jsxref("Object.preventExtensions()")}}. Returns a {{jsxref("Boolean")}}.
- {{jsxref("Reflect.set()")}}
- A function that assigns values to properties. Returns a {{jsxref("Boolean")}} that is
true
if the update was successful. - {{jsxref("Reflect.setPrototypeOf()")}}
- A function that sets the prototype of an object.
Specifications
Specification | Status | Comment |
---|---|---|
{{SpecName('ES6', '#sec-reflect-object', 'Reflect')}} | {{Spec2('ES6')}} | Initial definition. |
{{SpecName('ESDraft', '#sec-reflect-object', 'Reflect')}} | {{Spec2('ESDraft')}} |
Browser compatibility
{{CompatibilityTable}}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatVersionUnknown}} | {{CompatGeckoDesktop("42")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Feature | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | {{CompatNo}} | {{CompatNo}} | {{CompatGeckoMobile("42")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
See also
- The {{jsxref("Proxy")}} global object.
- The {{jsxref("Proxy.handler", "handler")}} object.