

Ask HN: Is there a consensus on the way to do JS inheritance? - ldidi

I work on a project that uses classes in JS. So far I&#x27;ve already used 3 different ways to do inheritance:<p>- Subclass.prototype = new Class()<p>- Subclass.prototype = Object.create( Class.prototype )<p>- Fiber: https:&#x2F;&#x2F;github.com&#x2F;linkedin&#x2F;Fiber<p>None of those solutions were acceptable: the two firsts have issues with method overriding and super() invocation, the latter is too verbose to implement.<p>It seems that most articles on the subject link to John Resig&#x27;s Simple Javascript Inheritance: http:&#x2F;&#x2F;ejohn.org&#x2F;blog&#x2F;simple-javascript-inheritance&#x2F;, but that one is from 2008 and I was wondering if there&#x27;s one &quot;modern&quot; way to do JS inheritance and that most people agree on.<p>Is there such a thing? Is there a library that implements it?<p>Side note: Please avoid things like &quot;you&#x27;re trying to do things that JS is not meant for&quot;, I&#x27;m just trying to answer the how, not the why.
======
tgriesser
I think your best bet would be going with something like node.js'
util.inherits, a standalone version for the browser can be found here:

[https://github.com/isaacs/inherits](https://github.com/isaacs/inherits)

