JavaScript Proxy
The Proxy Object
Proxy is a JavaScript Object with methods for low-level metaprogramming.
Proxy Syntax
const proxy = new Proxy(target, handler);
- target - the original object or function
- handler - an object with trap methods
Complete Proxy Handler Reference
Revised December 2025
| Method | Description |
|---|---|
| handler.apply() | Call a function |
| handler.construct() | Create object (like new) |
| handler.defineProperty() | Define a property |
| handler.deleteProperty() | Delete a property |
| handler.get() | Get a property |
| handler.getOwnPropertyDescriptor() | Get property descriptor |
| handler.getPrototypeOf() | Get the prototype of an object |
| handler.has() | Check if property exists |
| handler.isExtensible() | Check if object can grow |
| handler.ownKeys() | Get all keys (incl. symbols) |
| handler.preventExtensions() | Stop object from growing |
| handler.set() | Set a property |
| handler.setPrototypeOf() | Set the prototype of an object |
Proxy Traps
A trap is a function inside a Proxy handler. It runs whenever a specific operation is performed on the Proxy.
Below is a complete explanation of every JavaScript Proxy trap, and what triggers them.
| Trap Name | Triggered when |
|---|---|
| construct | An object is cretated (with new) |
| apply | A function is called |
| get | A property is read |
| set | A property is changed |
| has | Using the in operator |
| deleteProperty | A property is deleted |
| defineProperty | A property is defined |
| getOwnPropertyDescriptor | A property descriptor is retrieved |
| ownKeys | Properties are listed |
| getPrototypeOf | A prototype is retrieved |
| setPrototypeOf | A prototype is set |
| isExtensible | Extensibility is checked |
| preventExtensions | Existenibility is prevented |
JavaScript Internal Methods
All JavaScript objects have 13 internal methods.
Each method has a corresponding Proxy trap:
| Internal Operation | Proxy trap |
|---|---|
| [[Construct]] | construct() |
| [[Call]] | apply() |
| [[Get]] | get() |
| [[Set]] | set() |
| [[HasProperty]] | has() |
| [[Delete]] | deleteProperty() |
| [[DefineProperty]] | defineProperty() |
| [[GetOwnProperty]] | getOwnProperty() |
| [[OwnPropertyKeys]] | ownPropertyKeys() |
| [[IsExstensible]] | isExtensible() |
| [[PreventExstensions]] | preventExtensions() |
| [[GetPrototypeOf]] | getPrototypeOf() |
| [[SetPrototypeOf]] | setPrototypeOf() |
Note
Every Proxy trap has a Reflect method with the same name and signature.
| Internal Operation | Reflect Method |
|---|---|
| [[Construct]] | Reflect.construct() |
| [[Call]] | Reflect.apply() |
| [[Get]] | Reflect.get() |
| [[Set]] | Reflect.set() |
| [[HasProperty]] | Reflect.has() |
| [[Delete]] | Reflect.deleteProperty() |
| [[DefineProperty]] | Reflect.defineProperty() |
| [[GetOwnProperty]] | Reflect.getOwnProperty() |
| [[OwnPropertyKeys]] | Reflect.ownPropertyKeys() |
| [[IsExstensible]] | Reflect.isExtensible() |
| [[PreventExstensions]] | Reflect.preventExtensions() |
| [[GetPrototypeOf]] | Reflect.getPrototypeOf() |
| [[SetPrototypeOf]] | Reflect.setPrototypeOf() |