在抽象类的方法中,如何获取子类的属性?
abstract class Parent {
id: string;
logProps() {
// HOW can I log all properties of a child class
// and their values? For example, the name.
}
}
class Child extends Parent {
name: string;
constructor(name) {
super();
this.name = name;
}
}
const child = new Child("Daniel");
child.logProps();