Im amazed that even after all this time (jQuery has been around since 2006) we have to resort to adding a plugin or a custom function in order to implement namespaces in jQuery.
// USAGE:
// var myProject = $.namespace('com.foo.myProject');
namespace : function(){
var o, d;
$.each(arguments, function(i,v) {
d = v.split(".");
o = window[d[0]] = window[d[0]] || {};
$.each(d.slice(1), function(i2, v2){
o = o[v2] = o[v2] || {};
});
});
return o;
},
I mean this is a tiny piece of code for a concept that gets used in most Javascript projects and frameworks (above is based on the ext js implementation):
Why isnt this part of jQuery core build? Is there a reason besides "we just havent got around to it yet"?