Closure- sigleton -module
singleton only one instance. Module turned into an IIFE
JavaScript
var foo = (function CoolModule() {
var something = "cool";
var another = [1,2,3];
function doSomething() {
console.log( something );
}
function doAnother() {
console.log( another.join("!"));
}
return {
doSomething: doSomething,
doAnother: doAnother
};
})();
foo.doSomething();
foo.doAnother();