handler.setPrototypeOf()

The handler.setPrototypeOf() method is a trap for Object.setPrototypeOf().

Syntax

var p = new Proxy(target, {
  setPrototypeOf: function(target, prototype) {
  }
});

Parameters

The following parameters are passed to the setPrototypeOf method. this is bound to the handler.

target
The target object.
prototype
The object's new prototype or null.

Return value

The setPrototypeOf method does not return a value.

Description

The handler.setPrototypeOf method is a trap for Object.setPrototypeOf().

Interceptions

This trap can intercept these operations:

Invariants

If the following invariants are violated, the proxy will throw a TypeError:

  • If target is not extensible, the prototype parameter must be the same value as Object.getPrototypeOf(target).

Examples

Example is needed here.

Specifications

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

Browser compatibility

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

See also

Document Tags and Contributors

 Contributors to this page: fscholz, Srushtika, tasyfinso, arai
 Last updated by: fscholz,