Skip to main content
Version: 3.28.0

handler.getPrototypeOf()

The handler.getPrototypeOf() method is a trap for the [[GetPrototypeOf]] internal method.

Syntax

new Proxy(obj, {
getPrototypeOf(target) {
// …
}
});

Parameters

The following parameter is passed to the getPrototypeOf() method. this is bound to the handler.

  • target
    • : The target object.

Return value

The getPrototypeOf() method must return an object or null.

Description

Interceptions

This trap can intercept these operations:

Or any other operation that invokes the [[GetPrototypeOf]] internal method.

Invariants

If the following invariants are violated, the trap throws a TypeError when invoked.

  • getPrototypeOf() method must return an object or null.
  • If target is not extensible, Object.getPrototypeOf(proxy) method must return the same value as Object.getPrototypeOf(target).