Just wondering if I'm missing something here, as I tried the following:
(function() {
var thing = function() {
var doIt = function() {
console.log("just do it");
this.updateValue(5);
};
return {
updateValue: function(val) {
console.log('updating value: ' + val);
},
go: function() {
doIt();
}
}
};
var t = thing();
t.go();
}())
After running this code, "just do it" appears in the console followed by an error stating that "updateValue" is not a function.
I was pondering, can an internal/private function (like "doIt") call a public function (such as "updateValue")? It could be seen as poor design, and I have restructured my code to avoid doing so. Nonetheless, I am intrigued as to whether it is feasible.
Thanks for your assistance.