Created
December 24, 2014 19:57
-
-
Save krhoyt/7735b967d53eccf554ba to your computer and use it in GitHub Desktop.
Basic OOP template for JavaScript libraries.
This file contains 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
// Originally | |
// http://phrogz.net/js/classes/OOPinJS.html | |
function Proxy() | |
{ | |
// Private variables and methods | |
// Only priveleged | |
var MY_PRIVATE = "PRIVATE"; | |
var moar_private = null; | |
function doSomethingPrivate() | |
{ | |
console.log( "Something private." ); | |
} | |
// Priveleged methods | |
// Invoke publicly | |
// Access to private | |
this.doPriveleged = function( value ) | |
{ | |
console.log( "Priveledged." ); | |
doSomethingPrivate() | |
}; | |
// Public properties | |
this.public_property = "Public."; | |
} | |
// Public methods | |
Proxy.prototype.doSomethingPublic = function() { | |
console.log( "Something public." ); | |
}; | |
// Prototype properties | |
Proxy.prototype.stuff = "Stuff."; | |
// Static properties | |
Proxy.MOAR_STUFF = "Moar stuff."; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment