Accessing "Public" methods from "Private" methods in javascript class
- by mon4goos
Is there a way to call "public" javascript functions from "private" ones within a class?
Check out the class below:
function Class()
{
this.publicMethod = function()
{
alert("hello");
}
privateMethod = function()
{
publicMethod();
}
this.test = function()
{
privateMethod();
}
}
Here is the code I run:
var class = new Class();
class.test();
Firebug gives this error:
publicMethod is not defined: [Break on this error] publicMethod();
Is there some other way to call publicMethod() within privateMethod() without accessing the global class variable [i.e. class.publicMethod()]?