簡単な例:
self.curTabs = null;
$j.getJSON(url)
.done(function (response) {
self.curTabs = response.tabs;
_.each(self.curTabs, function (tab) {
tab.dataLoaded = true;
});
console.log(self.curTabs);
});
論理出力: [ 0: Object { dataLoaded: true, etc... }, 1: etc... ]
.
しかし、この例では:
self.curTabs = null;
$j.getJSON(url)
.done(function (response) {
self.curTabs = response.tabs;
_.each(self.curTabs, function (tab) {
tab.dataLoaded = true;
});
console.log(self.curTabs);
_.each(self.curTabs, function (tab) {
tab.dataLoaded = false;
});
});
非論理的な出力: [ 0: Object { dataLoaded: false, etc... }, 1: etc... ]
.
false
割り当てる前に変数が値を取得するのはなぜですか?