Skip to content

Instantly share code, notes, and snippets.

@jswhisperer
Created October 5, 2013 12:39
Show Gist options
  • Select an option

  • Save jswhisperer/6840462 to your computer and use it in GitHub Desktop.

Select an option

Save jswhisperer/6840462 to your computer and use it in GitHub Desktop.
JS Module Pattern
var batman = (function () {
var identity = "Bruce Wayne";
return {
fightCrime: function () {
console.log("Cleaning up Gotham.");
},
goCivilian: function () {
console.log("Attend social events as " + identity);
}
};
})();
// Outputs: undefined
console.log(batman.identity);
// Outputs: "Attend social events as Bruce Wayne"
batman.goCivilian();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment