Proxy.revocable

Creates a revocable Proxy object.

Revocable proxies are proxies that can be revoked using the revoke method of the returned object. Once a proxy is revoked, it will no longer be possible to use it.

Syntax

Proxy.revocable(target, handler)

Parameters

Return value

An object with two properties:

Examples

let bird = {
  species: 'sparrow',
}
let { proxy, revoke } = Proxy.revocable(bird, {})
print(proxy.species) // ok
revoke()
print(proxy.species) // error
sparrow

TypeError: revoked proxy