Created
July 1, 2013 13:40
-
-
Save kaleb/5900857 to your computer and use it in GitHub Desktop.
JavaScript Notes for a friend
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
function Constructor() { | |
// Private member only accessible w/in constructor | |
var privateVariable; | |
// Can access private members | |
this.privilegedMethod = function() { | |
//... | |
}; | |
} | |
Constructor.prototype = { | |
// When over-writing prototype, re-assign the constructor | |
constructor: Constructor, | |
publicVariable: null, | |
publicMethod: function() { | |
//... | |
} | |
} | |
Constructor.staticMethod = function() { | |
//... | |
}; | |
var obj = new Constructor(); | |
obj.privilegedMethod(); | |
obj.publicMethod(); | |
Constructor.staticMethod(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment