Last active
August 29, 2015 14:06
-
-
Save antoniocapelo/e6b631b941e588dd9736 to your computer and use it in GitHub Desktop.
Class Creation - Prototype 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) { | |
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