Classic module pattern
ar classicModulePattern=(function(){Modified module pattern
var greeting={text: "hi"};
return {
sayHi: function(){
console.log(greeting.text);
}
}
})();
The good thing about this module is that you can update it, you can remove and add attributes while in the classic module you will not be able to update the returned object.
var modifiedModulePattern= (function(){
var publicAPI={
sayHi: function(){
publicAPI.sayBye();
},
sayBye:function(){
console.log('Bye');
}
};
return publicAPI;
})();
modifiedModulePattern.sayHi();
No comments:
Post a Comment