玩笑过后

导航

模块

function coolModule(){
        var something = 'cool';
        var another = [1,2,3];
    
        function doSome(){
            console.log(something);
        }
        function doanother(){
            console.log( another.join( " ! " ) );
        }

        return {
            dosome:doSome,
            doanother:doanother
        }
    }

    var obj = coolModule();
    obj.dosome();
    obj.doanother();

利用闭包的模块化

posted on 2018-07-30 13:14  玩笑过后  阅读(72)  评论(0编辑  收藏  举报