Hacker News new | ask | show | jobs
by dkrvt 4010 days ago
I'm curious as I haven't found a good coding style guide about object inheritance in ES5.

I usually write this even though it's a bit verbose:

  function Child() {
    Parent.call(this);
  }
  Child.prototype = Object.create(Parent.prototype);
  Child.prototype.constructor = Child;
Any opinion on this or link to a good guide?
1 comments

ES6 actually solves this with it's new Class syntax.

  class Child extends Parent {
  }