这是一个扩展函数,须要初期加载的时候加载到适当的位置。函数
具体函数体以下:spa
$.namespace = function() { var a=arguments, o=null, i, j, d; for (i=0; i<a.length; i=i+1) { d=a[i].split("."); o=window; for (j=0; j<d.length; j=j+1) { o[d[j]]=o[d[j]] || {}; o=o[d[j]]; } } return o; };
使用的时候这样写,能够避免一长串的对象赋值:code
$.namespace('system.user'); $.system.user.funcA = function(){ }