views:

40

answers:

1

given i have the following block of code

(function(){    
    var mb = {
        abc:function(){
            //do something
        },
        xyz:function(width, height, site){
            //do something
        }
    };
})();

how do i make the method mb.abc accessible from the page, but not mb.xyz?

+4  A: 
var mb = function() {
    function xyz(width, height, site){
        // not visible outside
    }

    return {
        abc:function(){
            //do something
        }
    };   
}();

mb.abc() is public, but mb.xyz() is not.

psychotik
i get `mb.abc() is not a function` in firebug
Russ Bradberry
nevermind, i got it, you had an extra `)` in there
Russ Bradberry