News for hackers. Stuff that matters.
Re:JavaScript: prototype vs. class by geoelectric on Wednesday April 04, 2018 @07:41PM (#16760399)
To be absolutely fair, the pattern at the top is buggy in that you're supposed to also set

    Foo.prototype.constructor = Foo;
...after replacing the prototype object that way. MDN (for example) covers this in a few pages, including:

https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Ob...

That said, it's a pretty common bug, particularly with stuff like:

    Foo.prototype = Object.create(FooParent.prototype) // Crockford-style inheritance
    console.log(Foo.prototype.constructor.name) // "FooParent"

There are no comments on this comment yet.