if ordinary functions are put in setTimeout, which is a normal event loop mechanism, the code in setTimeout will be executed after the code in the main thread has been executed, as follows:
console.log("start")
setTimeout(function(){
console.log("setTimeout")
},0)
console.log("end")
output result:
:
:
the question I want to ask is that if the immediate execution function is used, will the setTimeout not be placed in the asynchronous event queue, or will it run the function in the asynchronous event queue and then go back to the main thread because the function is executed immediately? Thank you for the answer.