I know that there are lots of topics about how does the private/public methods work in JS, but none of them resolved the issue I'm currently experiencing.
As you can see below, I'm just trying to access a public method from a private method.
function Animal(name) {
this.name = name
}
Animal.prototype = (function()
{
var sitdown = function() {
console.log(this.name + ' sits down.');
standup();
};
return {
standup: function()
{
console.log(this.name+' stands up');
sitdown();
}
}
})();
var Tiger = new Animal("Tiger");
Tiger.standup();
Everything works until it gets to the standup() method.
can you please advise as how can I solve this?
Thanks, Alex