DEV Community

Discussion on: Javascript Event Loop for dummies 🤡

Collapse
 
hasnaindev profile image
Muhammad Hasnain

I don't understand one thing so I'm going to ask it.

Does the WebAPI calls and resolves our function and push the result to call stack? Or does it just waits for call stack to be clear and then hand over the function to it for normal execution?

Collapse
 
papidiagne30 profile image
Papa Abdoulaye Diagne

Hey! Thanks for asking 😊.
The WebAPI resolves the function, and pushes its callback into the queue. The callbacks in that queue are not called until the call stack is empty, then they're pushed to it in order of arrival.