This is my simplified example.
class BasePerson{
constructor(name){
this.name = name || "noname";
}
shout(){
var shoutMessage = this._talk() + "!!!!!";
console.log(shoutMessage);
}
}
class HappyPerson extends BasePerson{
constructor(name){
super(name);
this.message = "LA LA LA LA LA";
}
_talk(){
return this.message;
}
}
var person1 = new HappyPerson();
person1.shout(); //LA LA LA LA LA!!!!!
person1._talk(); //returns LA LA LA LA LA but I want _talk to be undefined
What I want to achieve is, making _talk method private when taking an instance of a HappyPerson but it should be reachable only at BasePerson class. How to achieve this in es6 ?