What is the cleanest format for writing javascript objects?
Currently I write mine in the following format
if (Namespace1 == null) var Namespace1 = {};
i
I use the following function:
jQuery.namespace = function() {
var a = arguments, o = null, i, j, d;
for (i=0; i
Then I can use this function to create a namespace just like this:
$.namespace("jQuery.namespace1");
Once I've created the namespace I can declare functions or whatever you want inside it:
a function:
$.namespace1.asyncRequest = function() {
[function body]
};
a constant:
$.namespace1.OFFSET = 10;
an object:
$.namespace1.request = { requestId: 5, protocol: 'JSON' };
I think it's simple and elegant :-)
Bye, Alex