[英]The '__proto__' property is deprecated with standard js
How to change the this.constructor.prototype.__proto__ = Error.prototype
as per the standard js rules. 如何按照标准js规则更改
this.constructor.prototype.__proto__ = Error.prototype
。 Standard Js is throwing The '__proto__' property is deprecated
. 标准Js抛出
The '__proto__' property is deprecated
。 So what will be correct solution for the same. 那么什么是相同的正确解决方案。
Thanks in advance. 提前致谢。
If you want to achieve (Prototypal) Inheritance, you can link the two objects as follows: 如果要实现(原型)继承,可以按如下所示链接两个对象:
this.constructor.prototype = Object.create(Error.prototype)
Although many browsers have supported the usage of __proto__
as means of accessing the internal [[Prototype]]
of an object, it has only been standardised in ES6 and its usage is still frowned upon. 尽管许多浏览器都支持使用
__proto__
作为访问对象内部[[Prototype]]
的手段,但它仅在ES6中进行了标准化,其使用方式仍然受到质疑。
Similar effect can be achieved by using ES6's Object.setPrototypeOf(..)
. 通过使用ES6的
Object.setPrototypeOf(..)
可以实现类似的效果。
Consult this for more information. 请参阅此以获取更多信息。
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.