JavaScript Proxy Object
A Proxy wraps an object and lets you intercept operations on it, such as reading or setting properties, through handler functions called traps.
Description
A Proxy creates a stand-in for another object, the target, and lets you intercept fundamental operations on it. The handler object defines traps, such as get, set, has, deleteProperty and apply, which run instead of the default behavior. Any operation without a trap goes straight to the target.
Proxies are used for validation, logging, default values, change tracking in UI frameworks and creating objects with dynamic properties. Inside a trap, the matching Reflect method performs the default action. Proxies add overhead to every operation, so avoid them in performance-critical code.
Some operations can't be intercepted, such as strict equality comparisons, and traps must respect certain rules called invariants; for example, a get trap can't report a different value for a non-writable, non-configurable property. Proxy.revocable() creates a proxy that can later be switched off, after which any operation on it throws a TypeError, which is useful for granting temporary access to an object.
Creating
new Proxy(target, handler)Example
Browser Support
The following information will show you the current browser support for the Proxy object. Hover over a browser icon to see the version that first introduced support for this object.
Desktop





Tablets & Mobile





