Skip to content

Instantly share code, notes, and snippets.

@jebai0521
Last active September 25, 2019 13:55
Show Gist options
  • Save jebai0521/2baa71e31a9250d6ebb9e2045b4ef715 to your computer and use it in GitHub Desktop.
Save jebai0521/2baa71e31a9250d6ebb9e2045b4ef715 to your computer and use it in GitHub Desktop.
Get the real class name in parent class with es6
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