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

  1. 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.
  2. Better return values: Reflect.set and Reflect.defineProperty return true/false instead of throwing or failing silently.
  3. Function form of operators: Reflect.has(obj, key) instead of key in obj, and Reflect.deleteProperty instead of delete, which is handy for functional code.
  4. Complete key listing: Reflect.ownKeys(obj) returns string and symbol keys, including non-enumerable ones.
  5. Safe function calls: Reflect.apply(fn, thisArg, args) works even if fn has its own apply property.

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

js
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 });
5
6console.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-enumerables
9
10// Boolean results instead of exceptions
11const 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 })); // false
14
15// The receiver matters for getters inside a Proxy
16const 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 proxy
20 return typeof value === "string" ? value.toUpperCase() : value;
21 },
22});
23console.log(upper.full); // ADA LOVELACE
24
25// apply and construct as functions
26console.log(Reflect.apply(Math.max, null, [3, 9, 4])); // 9
27const 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.

Open in study app