**namespace: 创建命名空间,近似于java的包定义,防止同名类冲突。
例子:
- namespace: function(){
- var a=arguments, o=null, i, j, d, rt;
- for (i=0; i<a.length; ++i) {
- d=a[i].split(".");
- rt = d[0];
- eval('if (typeof ' + rt + ' == "undefined"){' + rt + ' = {};} o = ' + rt + ';');
- for (j=1; j<d.length; ++j) {
- o[d[j]]=o[d[j]] || {};
- o=o[d[j]];
- }
- }
- }
其中eval('if (typeof ' + rt + ' == "undefined"){' + rt + ' = {};} o = ' + rt + ';') 中rt代表每一个动态类型,如:
if (typeof Ext == 'undefined'){Ext = {}} o=Ext;
将Ext.namespace赋值给Ext.ns简化写法
*******************************************************************************************