0

What does util.inherits do more than the following code:

constructor.prototype = Object.create(superconstructor.prototype);
OMar Mohamed
  • 303
  • 3
  • 10
  • Because if you only want one class to inherit the methods from another class, making them share the exact same methods is completely wrong. – Oriol Jul 09 '16 at 23:23
  • what about this `constructor.prototype = Object.create(superconstructor.prototype);` @Oriol – OMar Mohamed Jul 09 '16 at 23:29
  • Yes, but then restoring the `constructor` property is a good idea: `constructor.prototype.constructor = constructor`. Or with `defineProperty` to make it non-enumerable. – Oriol Jul 09 '16 at 23:33
  • and why should I to set the constructor property ? @Oriol I guess to retrieve the constructor later from an instance so that I can create a new one, right ?? – OMar Mohamed Jul 09 '16 at 23:45

0 Answers0