0

How to change the this.constructor.prototype.__proto__ = Error.prototype as per the standard js rules. Standard Js is throwing The '__proto__' property is deprecated. So what will be correct solution for the same.

Thanks in advance.

Shravan Jain
  • 720
  • 1
  • 11
  • 32

1 Answers1

1

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.

Similar effect can be achieved by using ES6's Object.setPrototypeOf(..).

Consult this for more information.

Hope this helps!

Parama Kar
  • 462
  • 3
  • 8