1. set-prototype-of
Object.setPrototypeOf Polyfill
set-prototype-of
Package: set-prototype-of
Created by: tjmehta
Last modified: Sun, 26 Jun 2022 18:19:46 GMT
Version: 1.0.0
License: MIT
Downloads: 76,969
Repository: https://github.com/tjmehta/set-prototype-of

Install

npm install set-prototype-of
yarn add set-prototype-of

Object.setPrototypeOf Polyfill (set-prototype-of)

Example

 require('set-prototype-of'); // Object.setPrototypeOf Polyfill
Object.setPrototypeOf(obj, proto);

Syntax

 Object.setPrototypeOf(obj, prototype);

Parameters

  • obj - The object which is to have its prototype set.
  • prototype - The object's new prototype (an object or null).

Description

Throws a TypeError exception if the object whose [[Prototype]] is to be modified is non-extensible according to Object.isExtensible(). Does nothing if the prototype parameter isn't an object or null (i.e., number, string, boolean, or undefined). Otherwise, this method changes the [[Prototype]] of obj to the new value.

Object.setPrototypeOf() is in the latest ECMAScript 6 standard draft. It is generally considered the proper way to set the prototype of an object, vs. the more controversial Object.prototype.__proto__ property.

License

MIT

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code