在我看來,這應該工作,但我不能看到到底是什麼問題。的Javascript關聯數組
錯誤林接收是「沒有定義DDROA」
誰能幫賜教。
var DDROA = {
AllowedRoutes : {
AR0 : {text : 'SomeText', value : 'SomeValue'},
AR1 : {text : 'SomeText2', value : 'SomeValue2'}
},
RouteContext : {
RC0 : {text : 'None', value : '0',
AllowedRoutes : new Array(
DDROA.AllowedRoutes.AR0 // An error occurs here
)
}
}
}
編輯
鬆弛的評論 你能幫助解釋爲什麼我必須完成聲明DDROA.AllowedRoutes然後再拍語句添加DDROA.RouteContext在一個單獨的stament。從本質上講,你告訴我,我必須
var DDROA = {AllowedRoutes : {}};
然後
DDROA.RouteContext = {};
爲什麼兩個單獨的語句。我做的事情就像
var Utilities = {
TextBased : {
someFunction : function(){
//do stuff
},
someFunction2 : function() {
Utilities.TextBased.someFunction();
}
}
};
有什麼區別?在我看來,我應該得到同樣的錯誤?
你濫用'Array'構造。 – SLaks 2010-04-23 00:44:52
請參閱我編輯的答案。 – SLaks 2010-04-23 01:14:54