Skip to content

Reflect

In one line

Reflect is a built-in object providing static methods that correspond to the fundamental object operations interceptable by Proxy.

In simple words

Reflect is a built-in object (not a constructor) whose methods are the same fundamental operations that Proxy traps intercept. Reflect.get(obj, key) reads a property, Reflect.set(obj, key, val) writes one, Reflect.has(obj, key) checks existence, Reflect.ownKeys(obj) lists own keys, and so on.

Reflect exists to make Proxy handlers easier to write: inside a trap you typically want to do something extra and then perform the default operation — Reflect provides that default. It also returns success booleans instead of throwing for some operations (like set on a read-only property), making error handling cleaner.

Before Reflect, these operations were scattered (Object.defineProperty, the in operator, delete). Reflect gathers them into one consistent, functional API. It is the companion to Proxy and the foundation of much modern meta-programming.

Example

javascript
const obj = { x: 1, y: 2 };

console.log(Reflect.get(obj, "x"));3 // 1
console.log(Reflect.has(obj, "y"));  // true
Reflect.set(obj, "z", 3);
console.log(Reflect.ownKeys(obj)); // ["x", "y", "z"]

// In a Proxy trap, forward the default behavior
const p = new Proxy(obj, {
  get(t, k) { return Reflect.get(t, k); },
});

Reflect methods mirror object fundamentals. In a Proxy trap, Reflect.get forwards the default read behavior.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary