Skip to content

Instantly share code, notes, and snippets.

Created March 17, 2013 15:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/5182152 to your computer and use it in GitHub Desktop.
Save anonymous/5182152 to your computer and use it in GitHub Desktop.
var CLASSNAME = (function(self){
var _private = 0;
function __init(){
//run self init stuff here
}
function returnPrivate(){
return _private;
}
function fnAdd(num){
_private+= num;
return returnPrivate();
}
function fnSubstract(num){
_private-= num;
return returnPrivate();
}
__init();
return {
fnAdd : fnAdd,
fnSubstract : fnSubstract
}
})(CLASSNAME || {});
//ForExample call CLASSNAME.fnAdd(2). Keep calling it and you will see the private keep changing
@andresgallo
Copy link

Module revealing pattern, with Augmentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment