如果我在hello.world.planet里面并且我引用了this.two,这将得到兄弟姐妹,我如何引用hello.planet而不引用变量的名称,类似于'this'
var hello = {
world: {
one: {
},
two: {
},
three: {
}
},
planet: {
}
}
答案 0 :(得分:0)
我并没有完全关注您想要引用的位置,但您可以尝试使用.bind()。我希望这就是你要追求的目标:
var hello = {
world: {
one: {
},
two: function() {
alert(this.planet);
}.bind(hello),
three: {
}
},
planet: {
}
}