Take for example:
var myobj; // this will be the object
(function () {
// private members
var name = "my, oh my";
// implement the public part
// note -- no `var`
myobj = {
// privileged method
getName: function () {
return name;
}
};
}());
myobj.getName(); // "my, oh my”
from the JavaScript Patterns book by Stefanov.
If you were to use the Chrome console, how would you locate the variable name, without the privileged method?
Take for example this code:
var a_1 = function(){console.log(this)}
a_1();
The window object that it logs, you can browse to a_1 - see the image attached (link below)
console logging the window object
Could we do the same with name variable in the anonymous immediate function?
Let me know if I have constructed my question clearly.