辞書(JavaScriptオブジェクト)に入力し、文字列インデックスを使用して辞書から値を取得しようとしています。何らかの理由でundefined
、値を取得しようとすると常に返されます。
私のコードは次のようになります。
var _gauges = {};
//fill the gauges
_gauges[gaugeName] = gaugeObject;
そして、私は次のようにそれにアクセスしようとします:
setValue: function (gaugeName, newValue) {
var thisGauge = _gauges[gaugeName]; //always undefined
console.log(_gauges); //output shows all the elements that were added to _gauges
if (thisGauge) {
thisGauge.setCell(0, 1, newValue);
}
}
私はここで何か間違ったことをしていますか?