Event Loop
JavaScript is a single-threaded synchronous language. JS engine uses call-stack to manage execution. but what if we have to perform asynchronous task? Event Loop Namaste JS event loop gif In case of event listeners document.getElementById("btn").addEventListener("click", function cb() { console.log("callback"); }); for above code; when this line is executed, Web API (window object) attaches click event listener to the callback function and pushes this callback to the callback queue upon occurrence of event “click”....