Most examples explaining the concurrency model of JavaScript in the browser list three parts: The call stack, the web api's, and the event queue. The normal process which is often described is that Web APIs are not handled by core ECMAScript and are handled by a web API; at this point they move into the event queue to wait until the call stack is empty to be executed. setTimeout is often used as an example to this process.
My questions are:
1.) since console.log is a web API, why does it not enter the event queue behind setTimeout? (does it even enter the event queue at all)?
2.) If it doesn't enter the event queue, what determines what APIs get pulled out of the call stack to go through the event loop process? Is it only those APIs which wait for something and have callbacks?
setTimeout(function(){
doSomething();
},0);
console.log('Hello World!');
asynchronousandliveor something may? The call toconsole.logabsolutely should be described assynchronous, it just reflects a live representation of the object generally.console.logcalls are sequenced - notice that the fact there is no console input (in the browser) except the REPL (which lets you enter a command again after everything has finished printing) greatly simplifies this.