Skip to content

Instantly share code, notes, and snippets.

@rpastorelle
Created November 20, 2012 19:06
Show Gist options
  • Save rpastorelle/4120265 to your computer and use it in GitHub Desktop.
Save rpastorelle/4120265 to your computer and use it in GitHub Desktop.
JS Module Pattern
var myModule = (function(){
var myItems = []; // private
return {
init: function(){
/*implementation*/
},
addItem: function(values){
myItems.push(values);
},
getItemCount: function(){ return myItems.length; }
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment