var x = 3;
    var foo = {
        x: 2,
        baz: {
            x: 1,
            bar: function() {
                return this.x;
            }
        }
    }
    var go = foo.baz.bar;
    console.log(go());//3 相当于window.go();
    console.log(foo.baz.bar());//1 this总是指向调用对象的

King
1.5k 声望33 粉丝

demo:[链接]