I have a class, and another class that extends that class.
class Shape {
constructor() {
return this;
}
}
class Circle extends Shape {
constructor() {
super();
return this;
}
}
let foo = new Circle();
I can get foo's class with
let className = foo.constructor.name
// returns string 'Circle'
Is it possible to get the name of foo's superclass ('Shape') in a similar manner?
Object.getPrototypeOf(Object.getPrototypeOf(foo)).constructor.name;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With