Skip to content

Instantly share code, notes, and snippets.

@kaleb
Created July 1, 2013 13:40
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 kaleb/5900857 to your computer and use it in GitHub Desktop.
Save kaleb/5900857 to your computer and use it in GitHub Desktop.
JavaScript Notes for a friend
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