Skip to content

Instantly share code, notes, and snippets.

@dlion
Created March 1, 2014 01:18
Show Gist options
  • Save dlion/9283339 to your computer and use it in GitHub Desktop.
Save dlion/9283339 to your computer and use it in GitHub Desktop.
var myNamespace = (function () {
var myPrivateVar, myPrivateMethod;
//Private counter variable
myPrivateVar = 0;
//Private function which logs any arguments
myPrivateMethod = function( foo ) {
console.log( foo );
};
return {
//Public variable
myPublicVar: "foo",
//Public function utilizing privates
myPublicFunction: function( bar ) {
//Increment private counter
myPrivateVar++;
//call our private methos using bar
myPrivateMethod( bar );
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment