Skip to content

Instantly share code, notes, and snippets.

@leecrossley
Created March 28, 2012 12:36
Show Gist options
  • Save leecrossley/2225824 to your computer and use it in GitHub Desktop.
Save leecrossley/2225824 to your computer and use it in GitHub Desktop.
Panda: without context splurge, callbacks or base library.
var panda = (function () {
var panda = {}, bambooLevel = 0, isAsleep = false;
function wakeUp() {
isAsleep = false;
}
panda.eatBamboo = function () {
bambooLevel = bambooLevel + 1;
};
panda.goToSleep = function () {
isAsleep = true;
setTimeout(wakeUp, 1000);
};
return panda;
})();
panda.eatBamboo();
panda.goToSleep();
@leecrossley
Copy link
Author

If you wanted to, instead of declaring "isAsleep" as a local variable, you could do panda.isAsleep is make it accessible outside in the wild. I've kept it in it's cage though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment