A disadvantage of this pattern is that if a private function refers to a public function, that public function can\'t be overridden if a patch is necessary. T
I would bind getName to this, which, it seems, points to the content returned in RMP.
function makeGreeter(name){
this.getName = function(){ return name;};
var _sayHello = function(){console.log("Hello, " + this.getName());};
return {
getName: getName,
sayHello: _sayHello
}
}
I prefer this, though:
function makeGreeter(name){
this.getName = function(){ return name;};
var _sayHello = function(){console.log("Hello, " + this.getName());};
var API = {
getName: getName,
sayHello: _sayHello
};
return API;
}