Skip to content

Instantly share code, notes, and snippets.

@beckettkev
Created May 13, 2015 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beckettkev/0a5b01f5f8b1920281ca to your computer and use it in GitHub Desktop.
Save beckettkev/0a5b01f5f8b1920281ca to your computer and use it in GitHub Desktop.
var MyCompany = MyCompany || {};
MyCompany.MyProject = MyCompany.MyProject || {};
MyCompany.MyProject.MyAmazingJavaScriptLibrary = MyCompany.MyProject.MyAmazingJavaScriptLibrary || {};
MyCompany.MyProject.MyAmazingJavaScriptLibrary.CoolStuffForKicks = function() {
//stuff in here is not exposed globally unless explicitly returned as such
var _iAmNotGlobalDude = function() {
console.log('Totally private. I am not running for no one external from this script ');
};
var _iAmNotGlobalButIDoRunAutomatically = function() {
console.log('I am private, but I get run once on script load "automatically"! ');
}();
var _iAmPrivateButIGetExposedGloballyByTheReturnStatement = function() {
console.log('I am private, but I get Exposed globally by the function return! ');
};
return {
GlobalExposedPrivates:_iAmPrivateButIGetExposedGloballyByTheReturnStatement
};
}(); ​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment