0Pricing
JavaScript Academy · Lesson

Creating a Proxy

Wrap objects to intercept operations.

What Is a Proxy?

A Proxy wraps an object and lets you intercept fundamental operations like reading, writing, and deleting properties.

You create one with new Proxy(target, handler), where the handler defines traps that customize behavior.

An Empty Handler

With an empty handler, the proxy behaves exactly like the target. Every operation passes straight through.

const target = { greeting: 'hello' };
const proxy = new Proxy(target, {});

console.log(proxy.greeting);
proxy.greeting = 'hi';
console.log(target.greeting);

All lessons in this course

  1. Creating a Proxy
  2. get and set Traps
  3. The Reflect API
  4. Practical Proxy Use Cases
← Back to JavaScript Academy