Is console.log Synchronize or asynchronous?

clipboard.png

clipboard.png

the output results of the two types are not the same
there is data in the obj output from the first picture, but it is undefined when it is obtained.


get the value once when you output from the console
when you click the drop-down to expand more, it will get the value again


clipboard.png

"i"

clipboard.png


console
console.log()


clipboard.png

JavaScript



clipboard.png


Synchronize next question


console is asynchronous. For more information, please take a look at this issue, which was accidentally discovered by a memory leak

.

https://github.com/nodejs/node/issues/2970

highlight console output is buffered and async.

but when it comes back to the topic, this place is really because of the citation problem


the first picture when you print obj.aaa, the object obj does not have the attribute of aaa. Of course, it is undefined. After you assign a value to obj.aaa='aaa', you can print out aaa

.
Menu