I have a class A and a child class B . now i want to print child class name from a static method of parent class. but both of them doesn’t use constructor or new keyword.
Class A {
static run() {
console.log("child class name");
}
}
class B extends A {}
B.run();
B.run() returning the Class name of B
2
Answers
Checking the prototype is one possible way?
I’m not sure i’ve really understood your question, let me know if i’m wrong..
You could simply use
this.name
(in the A class) to make B.run returns "B"As following :