How do Web APIs interact with the event loop in JavaScript?
You call a Web API (like setTimeout). The Web API runs the operation outside the engine. The engine continues. When the operation completes, the Web API pushes the callback to the microtask or macrotask queue. The event loop moves it to the stack when it is empty.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Web APIs in JavaScript Explained
Functions provided by the browser (or Node.js) that run outside the JS engine. Examples: setTimeout, fetch, DOM methods, localStorage, geolocation. They handle async operations and push callbacks to queues when done.
No. They are provided by the browser (or Node.js runtime). The JS engine only knows JavaScript. Web APIs are the host environment's extension to the language. This is why they are not available in a bare JS engine without a host.
setTimeout, setInterval, fetch, XMLHttpRequest, WebSocket, DOM methods (querySelector, addEventListener), localStorage, sessionStorage, IndexedDB, geolocation, Canvas, AudioContext, Worker, IntersectionObserver, MutationObserver.
Still have questions?
Browse all our FAQs or reach out to our support team
