Reflect
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2016.
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
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()
-
Calls a target function with arguments as specified by the
args
parameter. See alsoFunction.prototype.apply()
. Reflect.construct()
-
The
new
operator as a function. Equivalent to callingnew target(...args)
. Reflect.defineProperty()
-
Similar to
Object.defineProperty()
. Returns aBoolean
. Reflect.deleteProperty()
-
The
delete
operator as a function. Equivalent to callingdelete target[name]
. 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,undefined
otherwise. Reflect.getPrototypeOf()
-
Same as
Object.getPrototypeOf()
. Reflect.has()
-
The
in
operator 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 the target object's own (not inherited) property keys.
Reflect.preventExtensions()
-
Similar to
Object.preventExtensions()
. Returns aBoolean
. Reflect.set()
-
A function that assigns values to properties. Returns a
Boolean
that istrue
if the update was successful. Reflect.setPrototypeOf()
-
A function that sets the prototype of an object.
Especificaciones
Specification |
---|
ECMAScript Language Specification # sec-reflect-object |
Compatibilidad con navegadores
BCD tables only load in the browser