views:

30

answers:

1

I am using the famous module pattern for creating namespaces however its cumbersome to write ns1.ns2.member to access a member from ns3(ns1.ns2.ns3). I do not like using a shortcut var(_ns2=ns1.ns2) for this purpose also with statement considered harmfull so what is the better to handle this problem? is it possible to combine scope of namespaces or whatever? thanks.

var NS1 = (function ()
{
    function $(id)
    {
        return document.getElementById(id);
    }    

    return {
        $: $
    }
})();


NS1.NS2 = function()
{
    function someFunc()
    {
        // Do not want the below one.
        NS1.$('...');
        // Is there a way to access $ directly.
        // without defining a variable for it here or using with statement.
    }
}();
A: 
Pointy