- JavaScript
- Browser APIs, DOM Performance, and Client-Side Security
JavaScript DOM & Browser API Interview Questions
JavaScript browser API interview questions take frontend interviews beyond pure ECMAScript into how code executes within the browser platform. Expect in-depth questions on event capturing and bubbling phases, layout thrashing caused by forced synchronous reflows, and storage boundaries.
These modules break down the real-world performance and security implications of browser APIs. Master request cancellation using AbortController, learn why CORS errors cannot be resolved in client-side code, and build memory-efficient event delegation systems.
JavaScript DOM & Browser API Interview Questions: 7 lessons
1. DOM Events and Event Delegation
Interactive ReadyEvents in JavaScript propagate in three sequential phases, which event delegation builds on: capturing (window down to target), target, and bubbling (target up to window). Event delegation attaches a single event listener to an ancestor element to handle events from multiple current or future children efficiently using event.target.
2. DOM Traversal & Reflow
Interactive ReadyThe DOM (Document Object Model) in JavaScript is the browser's tree of nodes for the page: DOM traversal navigates those nodes, while reflow is the browser's expensive calculation of element geometry and layout. Batching DOM mutations with DocumentFragment and separating read operations from write operations eliminates layout thrashing and maintains 60fps rendering.
3. Web Storage, Cookies & Persistence
Interactive ReadylocalStorage in JavaScript, like sessionStorage (together the Web Storage API), stores client-side key-value string pairs without sending data to servers, while HTTP Cookies store small snippets that are transmitted with every HTTP request. Cookies support critical security flags like HttpOnly, Secure, and SameSite to mitigate XSS and CSRF.
4. Fetch API & AbortController
Interactive ReadyFetch in JavaScript uses the Fetch API, a modern Promise-based interface for network requests that rejects only on network failures, requiring manual inspection of response.ok for HTTP 4xx/5xx status codes. AbortController enables cancelling in-flight requests and managing request timeouts via AbortSignal.
5. CORS & Security Boundaries
Interactive ReadyCross-Origin Resource Sharing (CORS) is a browser security mechanism that restricts web applications from requesting resources from a different origin, and a CORS preflight request (an OPTIONS call) is how the browser asks the server for permission before a non-simple request. Preflight OPTIONS requests validate non-simple HTTP methods and headers before dispatching the actual request, safeguarding servers from unauthorized client interactions.
6. IntersectionObserver & Virtual Lists
Interactive ReadyList virtualization renders only items within the visible viewport plus an overscan buffer, positioning rendered elements with CSS translateY to achieve 60fps scrolling across 100,000+ items. IntersectionObserver asynchronously monitors element visibility without the performance overhead of continuous scroll event handlers.
7. Web Workers & Transferable Objects
Interactive ReadyWeb Workers offload heavy CPU tasks from the main thread into separate background threads with isolated memory. Transferable objects like ArrayBuffer transfer memory ownership in O(1) time without copying, detaching the buffer in the sender thread to prevent data races.
