Immediately invoked function expressions can be used to create a private scope while producing a public API.
var Module = (function() {
var privateData = 1;
return {
getPrivateData: function() {
return privateData;
}
};
})();
Module.getPrivateData(); // 1
Module.privateData; // undefined
See the Module Pattern for more details.