class Parent {
work = () => {
console.log('This is work() on the Parent class');
}
}
class Child extends Parent {
work() {
console.log("This is work() on the Child class ");
}
}
const kid = new Child();
kid.work();
为什么执行的是父类方法?如果父类改为非箭头函数,又是执行子类方法。