Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

JavaScript · Module

Reflect

Reflect is a namespace object containing static methods that invoke interceptable JavaScript object operations. It is primarily used to forward default behavior from Proxy traps.

How it works

Reflect is a namespace object whose static methods invoke JavaScript object internal methods, such as property access, assignment, construction, and function calls. It is especially useful inside Proxy traps when a trap should add behavior while preserving the operation's normal semantics.

Syntax

Reflect

Returns

Each static method returns the result specified by the corresponding operation; the exact return value depends on the method.

Key points

  • Reflect exposes static functions for explicitly invoking internal object operations.
  • Its method names correspond to Proxy handler trap operations.
  • Methods are accessed directly on Reflect rather than through instances.
  • Use Reflect in a trap when custom logic should preserve the operation's default behavior.
  • Proxy traps customize fundamental operations represented by object internal methods.
  • Each Reflect operation invokes the matching internal object method.

Common mistakes

  • Reflect cannot be called with new and is not callable as a function; use its static methods directly.

Example: Forward Proxy Operations with Reflect

const target = { value: 1 };
const proxy = new Proxy(target, {
  get(object, property, receiver) {
    console.log(`Reading ${String(property)}`);
    return Reflect.get(object, property, receiver);
  },
  set(object, property, value, receiver) {
    return Reflect.set(object, property, value, receiver);
  },
});

console.log(proxy.value);
proxy.value = 2;
console.log(proxy.value);

The proxy logs reads while Reflect forwards the intercepted operations using JavaScript's default object behavior.

When to use it

Forward Proxy traps

A Proxy trap needs to log, validate, or transform an operation while retaining ordinary JavaScript behavior.

Explicit reflective operations

Code needs to invoke property, construction, or function-call semantics explicitly rather than using syntax.

Implement meta-programming utilities

Meta-programming code needs operations that match Proxy handler trap semantics.

Interview questions

QWhat is Reflect?

Reflect is a built-in namespace object containing static methods that correspond to interceptable object internal methods. It is not a constructor or callable function.

Follow-up: Why is it commonly used in Proxy traps? It provides the default forwarding operation, allowing the trap to add behavior without manually reproducing ordinary semantics.

QHow do Reflect and Proxy work together?

A Proxy trap intercepts an operation, while the matching Reflect method performs the corresponding default internal operation. For example, a get trap can call Reflect.get with the target, property, and receiver.

Follow-up: Can Reflect bypass another proxy? No. The operation still goes through object internal methods, so a proxy target remains proxied.

QWhat are the main uses of Reflect?

Reflect methods use function-style forms of operations such as property lookup, assignment, construction, and invocation. This makes those operations explicit and useful for forwarding from traps.

Follow-up: What recursion risk exists? If a trap calls the corresponding Reflect method with the proxy as the target, the same trap can be triggered again indefinitely.

  • Proxy
  • Reflect.apply()
  • Reflect.construct()
  • Reflect.defineProperty()
  • Reflect.deleteProperty()
  • Reflect.get()
  • Reflect.getOwnPropertyDescriptor()
  • Reflect.getPrototypeOf()

Source: Reflect - JavaScript - MDN Web Docs. Checked 2026-10-15.