What is Reflect?
Reflect is a built-in object with static methods that perform the default behaviour of fundamental object operations (get, set, has, deleteProperty, ownKeys, apply, construct...), with the same names and arguments as Proxy traps.
Why it exists
- Companion to Proxy: inside a trap,
Reflect.get(target, prop, receiver)does exactly what the engine would have done, including getters and inheritance, so you can add behaviour and then forward cleanly. - Better return values:
Reflect.setandReflect.definePropertyreturntrue/falseinstead of throwing or failing silently. - Function form of operators:
Reflect.has(obj, key)instead ofkey in obj, andReflect.deletePropertyinstead ofdelete, which is handy for functional code. - Complete key listing:
Reflect.ownKeys(obj)returns string and symbol keys, including non-enumerable ones. - Safe function calls:
Reflect.apply(fn, thisArg, args)works even iffnhas its ownapplyproperty.
The receiver argument
Reflect.get(target, prop, receiver) passes receiver as this to getters. In a Proxy, forwarding the receiver ensures that getters reading other properties also go through the proxy, which matters for inheritance and reactivity.
Reflect vs Object
Many methods overlap (Object.getPrototypeOf vs Reflect.getPrototypeOf). The Reflect versions are designed for meta-programming: consistent arguments and boolean results instead of exceptions.
Reflect.construct
Calls a constructor with an arguments array and optionally a different new.target, useful when building factories or subclasses dynamically.
Code example
1const user = { name: "Ada", get greeting() { return `Hi, ${this.name}`; } };2const ID = Symbol("id");3user[ID] = 7;4Object.defineProperty(user, "secret", { value: "x", enumerable: false });56console.log(Reflect.has(user, "name"), Reflect.get(user, "greeting")); // true "Hi, Ada"7console.log(Reflect.ownKeys(user)); // ["name", "greeting", "secret", Symbol(id)]8console.log(Object.keys(user)); // ["name", "greeting"] - no symbols or non-enumerables910// Boolean results instead of exceptions11const frozen = Object.freeze({ a: 1 });12console.log(Reflect.set(frozen, "a", 2)); // false (no throw, even in strict mode)13console.log(Reflect.defineProperty(frozen, "b", { value: 1 })); // false1415// The receiver matters for getters inside a Proxy16const base = { first: "Ada", last: "Lovelace", get full() { return `${this.first} ${this.last}`; } };17const upper = new Proxy(base, {18 get(target, prop, receiver) {19 const value = Reflect.get(target, prop, receiver); // `this` in getters = the proxy20 return typeof value === "string" ? value.toUpperCase() : value;21 },22});23console.log(upper.full); // ADA LOVELACE2425// apply and construct as functions26console.log(Reflect.apply(Math.max, null, [3, 9, 4])); // 927const date = Reflect.construct(Date, [2026, 0, 15]);28console.log(date.getFullYear()); // 2026
Practice this question
Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the JavaScript set.