let MyApp = {}
MyApp.namespace = function(name) {
let parts = name.split('.')
console.log(parts)
let current = MyApp
for(let i in parts) {
if (!current[parts[i]]) { // 当前有没有这个属性
current[parts[i]] = {} // 创建
}
// 重置current。将current移到下一级继续查找属性装入
current = current[parts[i]]
}
}
MyApp.namespace('event')
MyApp.namespace('dom.style')
MyApp.namespace('a.b.c.d.e')
console.dir(MyApp)