我有一个班级,还有一个扩展该班级的班级。
class Shape {
constructor() {
return this;
}
}
class Circle extends Shape {
constructor() {
super();
return this;
}
}
let foo = new Circle();
我可以上 foo 的课
let className = foo.constructor.name
// returns string 'Circle'
是否可以以类似的方式获取 foo 的超类(“Shape”)的名称?
Object.getPrototypeOf(Object.getPrototypeOf(foo)).constructor.name;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)