set-prototype-of

2019-05-17 admin

set-prototype-of是什么

什么是set-prototype-of,Object.setPrototypeOf Polyfill

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

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-65144.html

文章标题:set-prototype-of

回到顶部