How to avoid calling child's method from parent class in javascript?

Viewed 46

Example:

class Parent {
    funcA() {this.funcB();}
    funcB() {console.log('FuncB in Parent');}
  }

class Child extends Parent {
    funcA() {super.funcA();}
    funcB() {console.log('FuncB in Child');}
  }

let child = new Child();
child.funcA();

Problem is I get FuncB in Child as a result.

I want to explitly make Parent's funcA always call its own funcB, ignoring if funcB is overloaded in child classes.

I tried this.__proto__.__proto__.funcB.call(this) in this case, but I assume there are better ways.

Can you point me right direction?

0 Answers
Related