(function(){
var privateVar = 10;
function privateFun = function(){
return false;
}
MyObject = function(){
};
MyObject.prototype.publicMethod = function(){
privateVarPP;
return privateFun();
}
})();
Can I write in this way?
function MyObject(){
var privateVar = 10;
function privateFun = function(){
return false;
}
MyObject.prototype.publicMethod = function(){
privateVarPP;
return privateFun();
}
}
I mean, there seems to be no difference between the two writing methods, both for code reuse and for private variables to be shared by instances.