Skip to content

Instantly share code, notes, and snippets.

@tonydub
Last active December 17, 2015 13:10
Show Gist options
  • Save tonydub/13f22894b3b7017ca5a7 to your computer and use it in GitHub Desktop.
Save tonydub/13f22894b3b7017ca5a7 to your computer and use it in GitHub Desktop.
var myNamespace = (function () {
var myPrivateVar, myPrivateMethod;
// A private counter variable
myPrivateVar = 0;
// A private function which logs any arguments
myPrivateMethod = function( foo ) {
console.log( foo );
};
return {
// A public variable
myPublicVar: "foo",
// A public function utilizing privates
myPublicFunction: function( bar ) {
// Increment our private counter
myPrivateVar++;
// Call our private method using bar
myPrivateMethod( bar );
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment