Last active
August 29, 2015 14:06
-
-
Save antoniocapelo/e6d368878e675a1da6c6 to your computer and use it in GitHub Desktop.
Class Creation - Module Pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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