What does the following Proxy demonstrate? const revocable = Proxy.revocable({}, { get: (t, k) => k }); console.log(revocable.proxy.foo); revocable.revoke(); console.log(revocable.proxy.bar);

JavaScript Professional Hard

JavaScript Professional — Hard

What does the following Proxy demonstrate? const revocable = Proxy.revocable({}, { get: (t, k) => k }); console.log(revocable.proxy.foo); revocable.revoke(); console.log(revocable.proxy.bar);

Key points

  • Revoking a Proxy object prevents any further operations on it
  • Accessing properties on a revoked proxy will throw a TypeError
  • The revoke() method is used to invalidate a Proxy object

Ready to go further?

Related questions