what are event loop in javascript code example

Example 1: event loop in javascript

The Event Loop has one simple job — to monitor the Call Stack 
and the Callback Queue. If the Call Stack is empty, it will 
take the first event from the 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.

Example 2: javascript event loop

console.log('Hi!');

setTimeout(() => {
    console.log('Execute immediately.');
}, 0);

console.log('Bye!');
Code language: JavaScript (javascript)