Reflect
Reflect es un objecto incorporado que proporciona metodos para interceptar operaciones de javascript. Los métodos son los mismos que los de proxy handlers. Reflect no es un objeto de funciones y por lo tanto no puede ser construido.
Descripción
A diferencia de la mayoria de los objetos globales, Reflect no es un constructor. No puede ser instanciado con un operador new o invocando el objecto Reflect como una función. Todas las propiedades y métodos de Reflect son estáticos (igual que los del objeto Math).
Métodos
El objeto Reflect proporciona las siguientes funciones estáticas con los mismos nombres de los métodos de proxy handler. Algunos de estos métodos son correspondientes a los métodos de Object.
Reflect.apply()(en-US)- Calls a target function with arguments as specified by the
argsparameter. See alsoFunction.prototype.apply(). Reflect.construct()(en-US)- The
newoperator as a function. Equivalent to callingnew target(...args). Reflect.defineProperty()(en-US)- Similar to
Object.defineProperty(). Returns aBoolean. Reflect.deleteProperty()(en-US)- The
deleteoperator as a function. Equivalent to callingdelete target[name]. Reflect.get()(en-US)- A function that returns the value of properties.
Reflect.getOwnPropertyDescriptor()(en-US)- Similar to
Object.getOwnPropertyDescriptor(). Returns a property descriptor of the given property if it exists on the object,undefinedotherwise. Reflect.getPrototypeOf()(en-US)- Same as
Object.getPrototypeOf(). Reflect.has()(en-US)- The
inoperator as function. Returns a boolean indicating whether an own or inherited property exists. Reflect.isExtensible()(en-US)- Same as
Object.isExtensible(). Reflect.ownKeys()(en-US)- Returns an array of the target object's own (not inherited) property keys.
Reflect.preventExtensions()(en-US)- 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()(en-US)- A function that sets the prototype of an object.
Especificaciones
| Specification | Status | Comment |
|---|---|---|
| ECMAScript 2015 (6th Edition, ECMA-262) La definición de 'Reflect' en esta especificación. |
Standard | Initial definition. |
| ECMAScript (ECMA-262) La definición de 'Reflect' en esta especificación. |
Living Standard | Reflect.enumerate has been removed. |
Compatibilidad en Navegadores
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help! (en-US)
| Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| Basic support | 49.0 | (Yes) | 42 (42) | Sin soporte | Sin soporte | 10 |
| Feature | Android | Chrome for Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|---|
| Basic support | 49.0 | 49.0 | (Yes) | 42.0 (42) | Sin soporte | Sin soporte | 10 |