Web APIs
Junior Questions
Using the Clipboard API?
Provides the ability to read and write to the system clipboard asynchronously, replacing the older synchronous `execCommand("copy")` approach.
What problems does this solve?
- Programmatic clipboard interaction is basic for "copy to clipboard" buttons and text editors.
What are Cookies?
Cookies are small pieces of data stored on the client and sent to the server with every HTTP request. Primarily used for session management, personalization, and tracking.
What problems does this solve?
- Differentiating between client-only storage (localStorage) and server-synced storage (cookies) is critical for security.
What is IntersectionObserver?
Provides a way to asynchronously observe changes in the intersection of a target element with an ancestor element or the top-level document's viewport.
What problems does this solve?
- The standard performant way to implement lazy loading and infinite scrolling.
What is ResizeObserver?
Allows you to observe the size of an element's content rect. Useful for building components that adapt to their container size rather than the whole viewport.
What problems does this solve?
- Fundamental for complex, responsive layouts where traditional media queries are insufficient.
What is the Canvas API?
The Canvas API provides a means for drawing graphics via JavaScript and the HTML `<canvas>` element. Used for graphs, games, photo manipulation, and real-time video processing.
What problems does this solve?
- Direct pixel manipulation is a core skill for frontend developers in data visualization or gaming.
What is the Geolocation API?
Allows the user to provide their location to web applications. Provides the device's latitude and longitude through GPS, Wi-Fi, or cellular towers.
What problems does this solve?
- Standard for localizing content, providing directions, or regional compliance.
What is the Notifications API?
Allows web applications to display system-level notifications to the user, even when the browser is in the background.
What problems does this solve?
- Notifications are a primary tool for increasing user retention and re-engagement.
What is the Vibration API?
Allows web apps to trigger a physical vibration on the user's device, primarily used for haptic feedback in mobile games or important alerts.
What problems does this solve?
- Haptic feedback is a "nice to have" mobile UX polish that shows attention to detail.
localStorage vs sessionStorage?
Both store key-value pairs as strings. `localStorage` persists even after the browser is closed. `sessionStorage` is cleared when the page session ends (e.g., when the tab is closed).
What problems does this solve?
- Basic storage comparison is a frequent junior-to-mid interview question.
Mid-Level Questions
Broadcast Channel API?
The Broadcast Channel API allows simple communication between different browser contexts (tabs, windows, iframes) on the same origin.
What problems does this solve?
- Cross-tab communication is essential for syncing auth or cart data across multiple open tabs.
How does requestAnimationFrame work?
Tells the browser that you wish to perform an animation and requests that the browser calls a specified function to update an animation before the next repaint.
What problems does this solve?
- Understanding how to time animations with the browser's refresh rate is vital for smooth motion.
What are Server-Sent Events (SSE)?
SSE allows servers to push data to web pages over HTTP. Unlike WebSockets, communication is unidirectional (server to client) and lighter-weight.
What problems does this solve?
- Knowing when to use SSE instead of full WebSockets is an important architectural trade-off discussion.
What are Web Workers?
Web Workers allow you to run script operations in a background thread separate from the main execution thread, preventing the UI from freezing during heavy processing.
What problems does this solve?
- Workers are vital for keeping large apps responsive during intensive computation.
What are WebSockets?
WebSockets provide a persistent, full-duplex communication channel between a client and a server, allowing for real-time bidirectional data exchange.
What problems does this solve?
- WebSockets are the industry standard for real-time features like chat or live updates.
What is File System Access?
Allows web apps to read, write, and save directly to files and folders on the user's local device, enabling "native-like" IDEs and editors in the browser.
What problems does this solve?
- Core to modern browser-based productivity applications (e.g., VS Code Web).
What is IndexedDB?
IndexedDB is a low-level API for client-side storage of significant amounts of structured data, including files/blobs. It uses indexes to enable high-performance searches of this data.
What problems does this solve?
- IndexedDB is the primary solution for truly large-scale offline storage in web applications.
What is MutationObserver?
Provides the ability to watch for changes being made to the DOM tree (e.g., added children, attribute changes) and react to them.
What problems does this solve?
- Critical for building tools that need to react to changes from third-party scripts or libraries.
What is requestIdleCallback?
Enables the scheduling of low-priority work to happen when the browser is idle, preventing foreground tasks (like animations or input) from being interrupted.
What problems does this solve?
- Strategic scheduling is a senior-level performance optimization technique.
What is the Cache API?
The Cache API is a system for storing and retrieving network requests and their corresponding responses. It's often used in combination with Service Workers to support offline experiences.
What problems does this solve?
- Cache API knowledge is fundamental for building Progressive Web Apps (PWAs).
Senior Questions
How do Storage Quotas work?
Browsers limit the amount of storage available to web applications based on disk space and usage. Applications can check current availability using `navigator.storage.estimate()`.
What problems does this solve?
- Understanding storage limits prevents applications from crashing when they exceed allowed space.
Payment Request API?
Allows web developers to use a standardized browser-provided interface to handle payment details, reducing friction and increasing conversion rates.
What problems does this solve?
- Standardizing checkout processes is a major win for e-commerce conversion.
Web APIs Best Practices?
Checklist: feature detect before using, handle permissions/errors gracefully, use workers for non-UI tasks, and always prioritize privacy and security (e.g., use HTTPS).
What problems does this solve?
- Summarizing cross-browser compatibility and safety ensures the developer builds resilient applications.
What are Service Workers?
Event-driven workers registered against an origin and a path. They act as proxy servers between web applications, the browser, and the network, enabling offline usage via caching.
What problems does this solve?
- The absolute cornerstone of Progressive Web Apps.
What is WebGL Basics?
WebGL (Web Graphics Library) is a JavaScript API for rendering high-performance interactive 3D and 2D graphics within any compatible web browser without the use of plug-ins.
What problems does this solve?
- WebGL knowledge is a prerequisite for advanced graphics work and libraries like Three.js.
What is WebRTC Basics?
Allows web applications and sites to capture and optionally stream audio and/or video media, as well as to exchange arbitrary data between browsers through peer-to-peer (P2P) connections.
What problems does this solve?
- WebRTC powers nearly all modern web-based video calling and P2P data sharing.
What is a SharedWorker?
A SharedWorker is a type of worker that can be accessed from several different contexts (tabs, iframes) on the same origin, allowing for communal state across tabs.
What problems does this solve?
- SharedWorkers are a more powerful alternative to Broadcast Channel for synchronized background tasks.
What is the MediaRecorder API?
The MediaRecorder interface provides functionality to easily record media. It's used for capturing audio or video streams from the user's camera/microphone or a `<canvas>` element.
What problems does this solve?
- Empowering users to record content directly in the browser is a standard modern app feature.
What is the Screen Capture API?
Provides the ability for users to select a screen, window, or tab to capture as a media stream, which can then be recorded or shared over the network.
What problems does this solve?
- Screen capture is fundamental for collaboration tools and screen recorders like Loom or Zoom clones.
What is the Web Audio API?
A powerful and versatile system for controlling audio on the Web, allowing developers to choose audio sources, add effects, and create audio visualizations.
What problems does this solve?
- Advanced audio manipulation is becoming common in web-based production tools and social platforms.
What is the Web Crypto API?
Provides a set of low-level cryptographic primitives (hashing, signature verification, encryption) that are fast and run in the browser's secure environment.
What problems does this solve?
- Essential for maintaining end-to-end security and handling sensitive user data locally.