JavaScript Proxy Methods

Beginner
5 min read
Updated: Nov 2026
14 method guides
Method index

About This Index

This page is the JavaScript Proxy Methods index. A Proxy has one static method, Proxy.revocable(), and thirteen traps: methods that you write in the handler object to catch actions on the Proxy. Each row below links to a full guide with syntax, examples you can run, and FAQs.

Learn what a Proxy is on /js/proxy. Use this page when you need a specific method such as handler.get() or handler.set().

Traps are written, not called.

You never call a trap such as handler.get() yourself. You put it in the handler object, like new Proxy(target, { get() { ... } }), and JavaScript calls it when someone reads a property of the Proxy. Only Proxy.revocable() is called directly.

How to Call a Proxy Method

Put the traps in a handler object, then create the Proxy:

JavaScript
const user = { name: "Ann", _token: "abc" };

const handler = {
  get(target, key, receiver) {
    return key in target ? Reflect.get(target, key, receiver) : "n/a";
  },
  has(target, key) {
    return !String(key).startsWith("_") && Reflect.has(target, key);
  }
};

const proxy = new Proxy(user, handler);
console.log(proxy.name);          // Ann
console.log(proxy.age);           // n/a
console.log("_token" in proxy);   // false

const { proxy: temp, revoke } = Proxy.revocable(user, {});
revoke();                         // temp can not be used any more

JavaScript Proxy Methods Table

All method guides in this JavaScript tutorial series (14 tutorials), grouped by what they do.

Create a Proxy you can switch off

1 method

A static method of Proxy, called directly.

MethodDescriptionTutorial
Proxy.revocable()Create a Proxy together with a revoke() function that switches it off for good.Open

Read, write and check properties

4 methods

The traps that are used the most.

MethodDescriptionTutorial
handler.get()Runs when a property is read. Give default values or add made-up properties.Open
handler.set()Runs when a value is assigned. The best place to validate data.Open
handler.has()Runs for the in operator. Hide names or build a custom check.Open
handler.deleteProperty()Runs for the delete operator. Protect properties from removal.Open

Define and list properties

3 methods

The traps behind descriptors, Object.keys() and for...in.

MethodDescriptionTutorial
handler.defineProperty()Runs when a property is defined, with Object.defineProperty() or sometimes with =.Open
handler.getOwnPropertyDescriptor()Runs when a property descriptor is read. Hide properties from Object.keys() and JSON.Open
handler.ownKeys()Runs when the keys are listed. Remove keys from Object.keys() and for...in.Open

Call functions and create objects

2 methods

These two traps need a function or a class as the target.

MethodDescriptionTutorial
handler.apply()Runs when the Proxy of a function is called. Log, change or block the call.Open
handler.construct()Runs when new is used on the Proxy of a class. It must return an object.Open

Work with prototypes

2 methods

Read and change what an object inherits from.

MethodDescriptionTutorial
handler.getPrototypeOf()Runs when the prototype is read, including by instanceof.Open
handler.setPrototypeOf()Runs when the prototype is changed. Block or limit the change.Open

Lock an object

2 methods

The traps for objects that cannot grow any more. Their answers are checked against the target.

MethodDescriptionTutorial
handler.isExtensible()Runs when JavaScript asks if new properties can be added. The answer must match the target.Open
handler.preventExtensions()Runs when someone locks the object. It must really lock the target before it returns true.Open

Frequently Asked Questions

It has one static method, Proxy.revocable(), and thirteen traps that you write in the handler: apply, construct, defineProperty, deleteProperty, get, getOwnPropertyDescriptor, getPrototypeOf, has, isExtensible, ownKeys, preventExtensions, set and setPrototypeOf.
The Proxy page explains the idea: target, handler, traps, and how a Proxy differs from getters and setters. This index lists the method guides so you can jump straight to the one you need.
No. Write only the ones you need. An action with no trap goes straight to the target, so a handler with just a set trap is a normal object that also checks every assignment.
get and set, by far. After them come has and deleteProperty, then ownKeys and getOwnPropertyDescriptor to hide properties, and apply to wrap functions.
Start with get() and set() to learn the basics, then read has() and deleteProperty(). When you are ready, learn apply() and construct() for functions, and ownKeys() for key lists. If you want the big picture first, read the Proxy page.

Start with handler.get()

Open the guide for catching property reads: syntax, examples, and FAQs.

handler.get() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

14 people found this page helpful