Skip to content

Instantly share code, notes, and snippets.

@antoniocapelo
Last active August 29, 2015 14:06
Show Gist options
  • Save antoniocapelo/e6d368878e675a1da6c6 to your computer and use it in GitHub Desktop.
Save antoniocapelo/e6d368878e675a1da6c6 to your computer and use it in GitHub Desktop.
Class Creation - Module Pattern
(function( global ) {
var ModPattern = function() {
function api1 (argument) {
return this.publicInstanceValue++;
}
function api2 (argument) {
return privateInstanceValue++;
}
function api3 (argument) {
return privatFn(argument);
}
function privatFn (argument) {
return 1+2;
}
var publicInstanceValue = 0;
var privateInstanceValue = 0;
return {
publicInstanceValue: publicInstanceValue,
api1: api1,
api2: api2,
api3: api3
}
};
ModPattern.staticValue = 200;
ModPattern.staticMethod = function(argument) {
return this.staticValue;
};
// expose our module to the global object
global.ModPattern = ModPattern;
})( this );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment