Skip to content

Instantly share code, notes, and snippets.

@CrabDude
Created February 10, 2011 21: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 CrabDude/821403 to your computer and use it in GitHub Desktop.
Save CrabDude/821403 to your computer and use it in GitHub Desktop.
Crockford's "Private Members in JavaScript"
// Public
function Constructor(...) {
this.membername = value;
}
Constructor.prototype.membername = value;
// Private
function Constructor(...) {
var that = this;
var membername = value;
function membername(...) {...}
}
// Privileged
function Constructor(...) {
this.membername = function (...) {...};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment