[ Web Proxy ]
URL:
Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Proxy/revocable [Back]  [Original]

Proxy.revocable() - JavaScript | MDN

This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

Proxy.revocable()

Baseline Widely available

This feature is well established and works across many devices and browser versions. Its been available across browsers since 2017 ..

Proxy.revocable() Proxy.

In this article

js
Proxy.revocable(target, handler)

target

Proxy. (, ).

handler

, , proxy, .

:

proxy

, new Proxy(target, handler).

revoke

() proxy.

Proxy.revocable() , Proxy(), revoke, . revoke .

revoke this. proxy revoke , revoke ( , , ). proxy revoke ( proxy revoke ).

revoke() : TypeError. , , , revoke() revoke() proxy revoke, . , . revoke target handler proxy, target , ( ), .

. , .

Proxy.revocable()

js
const revocable = Proxy.revocable(
  {},
  {
    get(target, name) {
      return `[[${name}]]`;
    },
  },
);
const proxy = revocable.proxy;
console.log(proxy.foo); // "[[foo]]"

revocable.revoke();

console.log(proxy.foo); //   TypeError
proxy.foo = 1; //  TypeError
delete proxy.foo; //   TypeError
typeof proxy; // "object", typeof    proxy- 

Specification
ECMAScript 2027 LanguageSpecification
# sec-proxy.revocable


Web Proxy Viewer  |  New URL  |  Original Page