SOURCE

function namespace(oNamespace, sPackage) {
    var package = sPackage.split('.');
    var obj = oNamespace;//类似于obj指向oNamespace的头节点,

    for (var i = 0; i < package.length; ++i) {

        // console.log(typeof obj[package[i]])
        if (typeof obj[package[i]] !== 'object') {
            obj[package[i]] = {};
        }

        obj = obj[package[i]];//这里obj也为null,因为指向了尾节点,所以下面那个代码不行,仔细体会一下
        console.log(i)
        console.log(obj)
        console.log(oNamespace)

    }


    console.log(oNamespace)
    return oNamespace;
}

namespace({ a: { test: 1, b: 2 } }, 'a.b.c.d')


console.log("测试1")

a = {}

a['c'] = {}
t = a['c']

t['d'] = {}

console.log(a)


console.log("测试2")

a = {}

a['c'] = {}


a['d'] = {}

console.log(a)
console 命令行工具 X clear

                    
>
console