прочитай книгу Javascript Patterns от Стояна Стефанова.
пара примеров кода "запаковки"
window.nya = new function(){
    var cache = {};
    this.getCache = function(){
        return cache;
    };
};
вот этот меня поразил, когда я его увидел в первый раз :
({
    css : function(el, prop){
        /*return css-prop*/
    },
    ajax : function(options){
        /*make ajax-request*/
    },
    init : function(name){
        var cache = {};
        this.getCache = function(){ return cache };
        delete this.init;
        window[name] = this;
    }
}).init("myToolbox");
myToolbox.ajax({ url : "foo", async : true }); //ajax-req.
myToolBox.css(document.body, "width"); // some width
myToolbox.getCache(); // {}
typeof myToolbox.cache // undefined.
typeof myToolbox.init // undefined.