function createNamespace(name){
var domains = name.split('.');
var cur_domain = window;
for(var i=0,len=domains.length;i<len;i++){
var domain = domains[i];
if(typeof cur_domain[domain] == 'undefined'){
cur_domain[domain] = {};
}
cur_domain = cur_domain[domain]
}
return cur_domain;
}
转载于:https://www.cnblogs.com/sky000/archive/2011/08/17/2143115.html