Last active
August 29, 2015 14:08
-
-
Save jbuffin/90ba3cb368f2b419c70b to your computer and use it in GitHub Desktop.
Library pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function MyLibrary(window) { | |
var privateVar; | |
function init() { | |
// do whatever is necessary here | |
privateVar = 'initial state'; | |
} | |
function publicMethod() { | |
// this function is exposed | |
} | |
function privateMethod() { | |
// this function is protected in the IIFE | |
} | |
window.MyLibrary = { | |
init : init, | |
publicMethod : publicMethod | |
}; | |
})(window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment