If you try to view the array in console.log(), it will reflect the processing after the call.
Therefore, the state at the time of console.log() call cannot be seen.
This is probably because the object contains a reference (address) rather than a value.
As an alternative move, you can use alert().