While iterating through an array of documents, I am encountering a strange issue where setting two properties to the same value results in them having different values when logged using console.log
.
Here is the code snippet:
this.logicItem.$promise.then(() => {
this.logicItem.getDocuments().$promise.then((docs: any) => {
docs.forEach(element => {
if (element.buildProgrammeActivityStatus === BUILD_PROGRAMME_ACTIVITY_STATUS.Confirmed ||
element.buildProgrammeActivityStatus === BUILD_PROGRAMME_ACTIVITY_STATUS.Complete) {
element.upper = true;
element.canUpload = true;
} else {
element.upper = false;
element.canUpload = false;
}
});
console.log(docs);
});
this.logicItem.reload(true);
});
Upon reviewing the output from the console log, it appears that even though both properties are set to true
, the value of canUpload
remains false
. Additionally, upper
reflects the expected behavior only within the true
block. What could be causing this unexpected behavior? Various iterations of looping methods have been attempted, yet the outcome persists.