Skip to content

Instantly share code, notes, and snippets.

@soarez
Created May 28, 2012
Embed
What would you like to do?
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