pętla zdarzeń
Event Loop : The event loop is the secret behind JavaScript's asynchronous
programming. JS executes all operations on a single thread, but using a
few smart data structures, it gives us the illusion of multi-threading.
Easy Definition :
The Event Loop has one simple job — to monitor the Call Stack and the
Callback Queue or Message Queue.
If the Call Stack is empty, it will take the first event from the
Callback queue and will push it to the Call Stack, which effectively runs it.
Such an iteration is called a tick in the Event Loop.
Each event is just a function callback.
Easiest explanation :
When any Asynchronous event occur such as setTimeOut or promises...
Then these task takes some time to complete I/O if they have any.
If they completed their I/O or don't have any, then they simply put into
message queue or callback queue. Then event loop will firstly execute the
call stack tasks and then look for callback or message queue and then execute it..
For more info visit : https://nodejs.dev/learn/the-nodejs-event-loop
Excited Emu