开发者

Making a Method Globally Accessible in Javascript

given i have the following block of code

(function(){    
    var mb = {
        abc:function(){
            //do something
        },
        xyz:function(width, heigh开发者_如何学Ct, site){
            //do something
        }
    };
})();

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜