Question 58
Question
Answer
const handler = { get: value => console.log(`Getting: ${value}`) };
const myProxy = new Proxy({ name: 'Alice' }, handler);
// ... use the proxy as usual...
console.log(myProxy.name); // Outputs "Getting: Alice"
// Revoke the proxy
const {revoke} = myProxy;
revoke();
// Now, trying to access the proxy will throw an error
console.log(myProxy.name); // Throws TypeError: Cannot read property 'name' of undefinedLast updated