http://addyosmani.com/resources/essentialjsdesignpatterns/book/#modulepatternjavascript
I was going through the above master piece. I am still not able to get two things from the above article.
var myRevealingModule = (function () {
var privateVar = "Ben Cherry",
publicVar = "Hey there!";
function privateFunction() {
console.log( "Name:" + privateVar );
}
function publicSetName( strName ) {
privateVar = strName;
}
function publicGetName() {
privateFunction();
}
// Reveal public pointers to
// private functions and properties
return {
setName: publicSetName,
greeting: publicVar,
getName: publicGetName
};
})();
myRevealingModule.setName( "Paul Kinlan" );
Related question: JavaScript design pattern: difference between module pattern and revealing module pattern?
I understood many parts from the above question. Can anyone convert the above revealing module pattern
into a traditional module pattern
, so that i can visualize the difference.