In vanilla JS can eventloop take a function from the callback queue and push it onto the callstack even before the JS engine completes executing Global Execution Context.
Question posted in Javascript
A very good W3school tutorial can be found here.
A very good W3school tutorial can be found here.
2
Answers
The "event loop" is not ECMAScript ("vanilla") terminology. The specification does however define some rules that a host should follow when dealing with jobs. One of those rules is that the engine does not initiate any queued jobs while JavaScript code is still executing. A job only gets its turn when code has run to completion and the call stack is empty.
See the ECMAScript spec on Jobs and Job Queues:
And also Jobs and Host Operations to Enqueue Jobs:
No, in vanilla JavaScript, the event loop cannot take a function from the callback queue and push it onto the call stack before the JavaScript engine (example V8) completes executing the Global Execution Context.
JavaScript Execution
setTimeout
,setInterval
,setImmediate
, I/O events, UI rendering events..then()
,.catch()
,.finally()
),MutationObserver
callbacks,process.nextTick()
JavaScript Event Loop – Execution Order
requestAnimationFrame
)Further reading