Some thing I started doing recently. Before this my javascript code was ugly as hell. Javascript is one of the languages that supports functional programming and the best way is to go fully functional with Higher Order Javascript. Javascript provides this nice way of faking scope.

(function () {

var x = ...;

})();

and this can be used like this for app initialization.