Inherits

In javascript there are many way to do Prototype inheritance.

ES6 abstracts this out using extends. ie. Student extends User.

So does Node, but instead uses inherit method, so as usual this just replace the objects prototype with a new prototype that links to the parent and the method looks something like this…

Util.js

// util.js
ctor.prototype = Object.create(superCtor.prototype, {
   constructor: {
     value: ctor,
     enumerable: false,
     writable: true,
     configurable: true
   }
});
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License