Skip to content

Instantly share code, notes, and snippets.

@antoniocapelo
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoniocapelo/e6b631b941e588dd9736 to your computer and use it in GitHub Desktop.
Save antoniocapelo/e6b631b941e588dd9736 to your computer and use it in GitHub Desktop.
Class Creation - Prototype Pattern
(function(global) {
function OOPPattern(value) {
this.publicInstanceValue = value || 10;
var privateValue = 0;
var privatFn = function(argument) {
return 1 + 2;
}
this.api2NeedsPrivateValue = function(argument) {
return privateValue++;
};
this.api3NeedsPrivateFn = function(argument) {
return privatFn(argument);
};
}
OOPPattern.prototype.api1 = function(argument) {
return this.publicInstanceValue++;
};
OOPPattern.staticValue = 200;
OOPPattern.staticMethod = function(argument) {
return this.staticValue;
};
global.OOPPattern = OOPPattern;
})(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment