var Module = (function() {
var privateMethod = function() {
console.log('Private method');
}
return {
publicmethod1: function() { console.log('first'); },
publicmethod2: function() { console.log('second'); }
}
})();
console.log(Module.publicmethod1());
console.log(Module.publicmethod2());
Completely contrary to my expectation ,i am getting
first
undefined
second
undefined
. What i was expecting is first and then second but not undefined .What is the reason for this undefined ?