Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

12
  • 66
    Worth mentioning that this doesn't work if you are using ES6 features via a transpiler, such as Babel, since subclasses must extend a class.
    – aaaidan
    Commented Jan 6, 2016 at 1:01
  • 8
    If you are using babel and are on node > 5.x you shouldn't be using the es2015 preset but npmjs.com/package/babel-preset-node5 would allow you to use native es6 extends plus more
    – Ace
    Commented Jun 16, 2016 at 7:09
  • 109
    For ease of maintaining, use this.name = this.constructor.name; instead. Commented Feb 2, 2018 at 10:09
  • 4
    This already works in the latest babel preset, they fixed the instanceof issue, also minified bugs are probably wrong minifier configs
    – Nicolas NZ
    Commented May 16, 2019 at 19:10
  • 11
    @КонстантинВан That's unfortunately only an option without class-name minification.
    – John Weisz
    Commented Feb 12, 2020 at 14:34