Race condition for objects logged in console (javascript)
I was coding in JavaScript, running my code in a browser and using the console. I noticed that logged objects might not reflect the properties of that object at the time it was logged. This can occur if you twist open an object in the debugger after it has been logged. This occurs in Firefox and Chrome. The following example shows the issue. I make an object, then set a timeout to update a property. Then I log the object and the property. The property is not set when it is logged, so it is undefined (as seen in the screenshot). But, if you twist open the object after the timeout has completed, it will show that the object has the updated property (also seen in the picture). Is there a way to avoid this? (i.e. ensure the object retains its properties at the time it was logged?).