A short example:
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);
});
Logical output: [ 0: Object { dataLoaded: true, etc... }, 1: etc... ]
.
But with this example:
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;
});
});
Illogical output: [ 0: Object { dataLoaded: false, etc... }, 1: etc... ]
.
Why the variable get the value false
before I assign it?