My first stab into the solution revolves around idea of offering to the user the possibility of sharing whatever is inside the JS namespace. Usually people want exactly the opposite. But sometimes the sharing concept is necessary.
Namespace conctruct does not exist in JS so we have to define it first. Here it is :
JS namespace is clustering of JS types and values.
Simple as that. JS types are var’s, functions, arrays and objects. The term ‘clustering’ is used to describe a set of before mentioned types and values , which are grouped somehow using the JS language syntax and features.
The JS type used for ‘clustering’ is naturally a Function. Which in JS is kind-of-a Object which is kind-of-a Array. Why Function? We simply use the Function because the resulting JS code will look more ‘natural’ as a ‘group of JS things’ or a ‘cluster’ or a ‘namespace’. When using a Function, everything to be clustered is naturally inside the opening and closing brace. The resulting source code looks somewhat like a namespace in Java, C# or C++.
This is the concept and now, here is my first implementation of what I said above.