0👍
Since the data is set async, the property is undefined
at the time it’s logged. The only reason you see it when logging the object is thanks to the console’s ability to update objects/arrays. It updates itself to show the current value when you click an object to view the properties.
This only works for references (like objects / arrays) because the console uses that reference to update itself.
So when you log the non-object property, you see the data as it was at the time of the log: undefined
. But when you log the object, and then click to expand properties, you see the data as it is now.
Source:stackexchange.com