ECMAScript® 2024 Language Specification

Draft ECMA-262 / February 15, 2024

28.2 Proxy Objects

28.2.1 The Proxy Constructor

The Proxy constructor:

  • is %Proxy%.
  • is the initial value of the "Proxy" property of the global object.
  • creates and initializes a new Proxy object when called as a constructor.
  • is not intended to be called as a function and will throw an exception when called in that manner.

28.2.1.1 Proxy ( target, handler )

This function performs the following steps when called:

  1. If NewTarget is undefined, throw a TypeError exception.
  2. Return ? ProxyCreate(target, handler).

28.2.2 Properties of the Proxy Constructor

The Proxy constructor:

  • has a [[Prototype]] internal slot whose value is %Function.prototype%.
  • does not have a "prototype" property because Proxy objects do not have a [[Prototype]] internal slot that requires initialization.
  • has the following properties:

28.2.2.1 Proxy.revocable ( target, handler )

This function creates a revocable Proxy object.

It performs the following steps when called:

  1. Let proxy be ? ProxyCreate(target, handler).
  2. Let revokerClosure be a new Abstract Closure with no parameters that captures nothing and performs the following steps when called:
    1. Let F be the active function object.
    2. Let p be F.[[RevocableProxy]].
    3. If p is null, return undefined.
    4. Set F.[[RevocableProxy]] to null.
    5. Assert: p is a Proxy exotic object.
    6. Set p.[[ProxyTarget]] to null.
    7. Set p.[[ProxyHandler]] to null.
    8. Return undefined.
  3. Let revoker be CreateBuiltinFunction(revokerClosure, 0, "", « [[RevocableProxy]] »).
  4. Set revoker.[[RevocableProxy]] to proxy.
  5. Let result be OrdinaryObjectCreate(%Object.prototype%).
  6. Perform ! CreateDataPropertyOrThrow(result, "proxy", proxy).
  7. Perform ! CreateDataPropertyOrThrow(result, "revoke", revoker).
  8. Return result.