Last active
September 25, 2019 13:55
-
-
Save jebai0521/2baa71e31a9250d6ebb9e2045b4ef715 to your computer and use it in GitHub Desktop.
Get the real class name in parent class with es6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A { | |
constructor() { | |
console.log('constructor instance class', new.target.name); | |
} | |
} | |
class B extends A { | |
constructor() { | |
super(); | |
} | |
} | |
new B(); | |
// Output | |
// constructor instance class B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment