我有一個對象的結構/層次類似下面的功能:稱爲「超級」 JavaScript對象
var obj = {
dimensions : {
x : 100,
y : 100,
w : 300,
h : 400,
cmp : function() {
return this.x + this.y;
}
},
definition : {
base : {
rect1 : {
// how do I get the value of dimensions.x ??
// or, for that matter, is there a way I could call dimensions.cmp()?
},
rect2 : {
// things go here
}
}
}
};
我的問題是:是要能夠從內部獲得dimensions.x的價值dimensions.definition.rect1函數?
非常感謝!我以爲這是因爲某些原因不允許的。我曾嘗試過,但似乎我在做一些愚蠢的事情。再次感謝。 – bibhas 2010-07-03 07:09:29