|
|
|
|
|
by geoelectric
3001 days ago
|
|
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"
|
|