Skip to content

Instantly share code, notes, and snippets.

@soarez
Created May 28, 2012 09:49
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 soarez/2818228 to your computer and use it in GitHub Desktop.
Save soarez/2818228 to your computer and use it in GitHub Desktop.
Private state
var @priv = {};
function Animal() {
priv[this] = {};
priv[this].walked = false;
}
Animal.prototype.walk = function walk() {
console.log('walking...')
priv[this].walked = true
}
Animal.prototype.hasBeenWalked = function hasBeenWalked() {
return priv[this].walked
}
module.exports = Animal;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment