开发者

Making a Method Globally Accessible in Javascript

开发者 https://www.devze.com 2022-12-22 16:11 出处:网络
given i have the following block of code (function(){ var mb = { abc:function(){ //do something }, xyz:function(width, heigh开发者_如何学Ct, site){

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

精彩评论

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

关注公众号