Namespaces common pattern

Namespaces common pattern

var ns = (function() {
    // local stuff
    function foo() {}
    function bar() {}
    function baz() {} // this one stays invisible

    // stuff visible in namespace object
    return {
        foo : foo,
        bar : bar
    };
})();

 

Leave a Reply

Your email address will not be published. Required fields are marked *


*