代码模式:闭包最强大的用途模块

<script>
    function CoolModular(){
        var something = "something";
        var another = [1,2,3];
        function doSomething()
        {
            console.log(something);
        }
        function doAnother()
        {
            console.log(another.join("!"));
        }
        return {
            doSomething:doSomething,
            doAnother:doAnother
        }
    }
    var cool = CoolModular();
    cool.doSomething();//something
    cool.doAnother();//1!2!3!
</script>