- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Proxy
JavaScript Performance
JavaScript Proxy
A
Proxywraps an object and lets you intercept what happens when it is used.
Reading a property, writing one, even checking if it exists - all of it can be intercepted.
This is how libraries build reactive objects that notice when you change them.
Example
Example
javascript
const target = { name: "Ada" };
const handler = {
get(obj, key) {
return obj[key];
}
};
const proxy = new Proxy(target, handler);
console.log(proxy.name);