I'm officially losing my mind. Am I missing something about javascript scope?
this.allUnits = {/*old data*/};
this.reconfigure = ( newData ) => {
console.log( newData.allUnitsArray ); // correct
this.allUnits = {};
for( var i = 0; i < newData.allUnitsArray.length; ++i ) {
var piece = newData.allUnitsArray[i];
console.log( piece ); // correct
this.allUnits[ piece.uid ] = piece;
console.log( this.allUnits[piece.uid] ); // correct
}
console.log( this.allUnits ); // *SOME* ELEMENTS STILL REFERENCE OLD DATA!?!?
};
It isn't possible for any other code to be executing between the end of the for loop and the next console log, is it?
Many thanks in advance for your help. :)