Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 함께 해서 번역을 마치도록 도와 주세요!

The Proxy.revocable() method is used to create a revocable Proxy object.

Syntax

Proxy.revocable(target, handler);

Parameters

target
A target object (can be any sort of objects, including a native array, a function or even another proxy) or function to wrap with Proxy.
handler
An object whose properties are functions which define the behavior of the proxy when an operation is performed on it.

Return value

A newly created revocable Proxy object is returned.

Description

A revocable Proxy is an object with following two properties {proxy: proxy, revoke: revoke}.

proxy
A Proxy object created with new Proxy(target, handler) call.
revoke
A function with no argument to invalidate (switch off) the proxy.

If the revoke() function gets called, the proxy becomes unusable: Any trap to a handler will throw a TypeError. Once a proxy is revoked, it will remain revoked and can be garbage collected. Calling revoke() again has no effect.

Examples

var revocable = Proxy.revocable({}, {
  get: function(target, name) {
    return "[[" + name + "]]";
  }
});
var proxy = revocable.proxy;
console.log(proxy.foo); // "[[foo]]"

revocable.revoke();

console.log(proxy.foo); // TypeError is thrown
proxy.foo = 1           // TypeError again
delete proxy.foo;       // still TypeError
typeof proxy            // "object", typeof doesn't trigger any trap

Specifications

Specification Status Comment
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'Proxy Revocation Functions' in that specification.
Standard Initial definition.
ECMAScript 2017 Draft (ECMA-262)
The definition of 'Proxy Revocation Functions' in that specification.
Draft  

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) 34 (34) No support No support No support
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support No support No support 34 (34) No support No support No support

See also

문서 태그 및 공헌자

 이 페이지의 공헌자: ibratoev, north-is-northwest, fscholz, xushu42, ziyunfei, arai
 최종 변경: ibratoev,