Reflect
大约 1 分钟
Reflect
模块
es.reflect.apply
es.reflect.construct
es.reflect.define-property
es.reflect.delete-property
es.reflect.get
es.reflect.get-own-property-descriptor
es.reflect.get-prototype-of
es.reflect.has
es.reflect.is-extensible
es.reflect.own-keys
es.reflect.prevent-extensions
es.reflect.set
es.reflect.set-prototype-of
类型
namespace Reflect {
function apply(
target: Function,
thisArgument: any,
argumentsList: Array<any>
): any;
function construct<A extends readonly any[], R>(
target: new (...args: A) => R,
argumentsList: A,
newTarget?: new (...args: any) => any
): Object;
function defineProperty(
target: Object,
propertyKey: PropertyKey,
attributes: PropertyDescriptor
): boolean;
function deleteProperty(target: Object, propertyKey: PropertyKey): boolean;
function get(target: Object, propertyKey: PropertyKey, receiver?: any): any;
function getOwnPropertyDescriptor(
target: Object,
propertyKey: PropertyKey
): PropertyDescriptor | void;
function getPrototypeOf(target: Object): Object | null;
function has(target: Object, propertyKey: PropertyKey): boolean;
function isExtensible(target: Object): boolean;
function ownKeys(target: Object): Array<string | symbol>;
function preventExtensions(target: Object): boolean;
function set(
target: Object,
propertyKey: PropertyKey,
value: any,
receiver?: any
): boolean;
function setPrototypeOf(target: Object, proto: Object | null): boolean; // required __proto__ - IE11+
}
入口点
core-js(-pure)/es|stable|actual|full/reflect
core-js(-pure)/es|stable|actual|full/reflect/apply
core-js(-pure)/es|stable|actual|full/reflect/construct
core-js(-pure)/es|stable|actual|full/reflect/define-property
core-js(-pure)/es|stable|actual|full/reflect/delete-property
core-js(-pure)/es|stable|actual|full/reflect/get
core-js(-pure)/es|stable|actual|full/reflect/get-own-property-descriptor
core-js(-pure)/es|stable|actual|full/reflect/get-prototype-of
core-js(-pure)/es|stable|actual|full/reflect/has
core-js(-pure)/es|stable|actual|full/reflect/is-extensible
core-js(-pure)/es|stable|actual|full/reflect/own-keys
core-js(-pure)/es|stable|actual|full/reflect/prevent-extensions
core-js(-pure)/es|stable|actual|full/reflect/set
core-js(-pure)/es|stable|actual|full/reflect/set-prototype-of
示例
示例:
let object = { a: 1 };
Object.defineProperty(object, "b", { value: 2 });
object[Symbol("c")] = 3;
Reflect.ownKeys(object); // => ['a', 'b', Symbol(c)]
function C(a, b) {
this.c = a + b;
}
let instance = Reflect.construct(C, [20, 22]);
instance.c; // => 42