Javascript Namespacing

A good practice for organising javascript code is through the use of namespaces. In javascript this entails encapsulating related functions within a function. An example is below:

var yourNamespace = function(){
    
    function method1(){}
    
    function method2(){}
    
    function method3(){}

    return {
        init: function(){
            method1();
            method2();
        },
        run: function(){
            method3();
        }
    }
    
}();