Skip to content
tezvyn:

All bites

The whole library, newest first. Filter by what you are here for, or pick a topic if you already know.

8668 bites

Page 116

How do you programmatically play, pause, and dynamically set a video source?
TypeScript & Web APIs2 min read

How do you programmatically play, pause, and dynamically set a video source?

Your grasp of HTMLMediaElement's imperative API and the play() Promise. Query the video, attach play() and pause() to buttons, and set src or swap source children then call load(). Treating play() as synchronous or changing src without load().

Design a Service Worker caching strategy for a news app
TypeScript & Web APIs2 min read

Design a Service Worker caching strategy for a news app

Cache First for the app shell, Stale-While-Revalidate for static assets, and Network First for article APIs.

Explain Network First vs Cache First caching and when to use each
TypeScript & Web APIs2 min read

Explain Network First vs Cache First caching and when to use each

Tests matching caching strategy to asset freshness. Cache First serves static assets from the Cache API, falling back to network. Network First fetches fresh content, falling back to cache offline.

Describe the Service Worker lifecycle and cache versioning
TypeScript & Web APIs2 min read

Describe the Service Worker lifecycle and cache versioning

Tests your grasp of the Service Worker lifecycle and cache versioning. A strong answer sequences register, install, activate, and fetch; notes install precaches assets while activate purges old caches and finalizes takeover.

Pass data to a Web Worker and transfer an ArrayBuffer efficiently
TypeScript & Web APIs2 min read

Pass data to a Web Worker and transfer an ArrayBuffer efficiently

Tests postMessage clone versus transferable objects for zero-copy transfer. Good answers note postMessage copies by default, but ArrayBuffer can move via transfer list, neutering the original.

SPA back button: what event fires and how do you handle it?
TypeScript & Web APIs2 min read

SPA back button: what event fires and how do you handle it?

Tests History API literacy. Strong answer: popstate event, PopStateEvent type, restore UI via event.state, and zero-delay setTimeout for DOM sync. Red flag: confusing popstate with pushState or using hashchange for modern History API routing.

What is a Service Worker's role and key PWA capability?
TypeScript & Web APIs2 min read

What is a Service Worker's role and key PWA capability?

Tests understanding of the Service Worker as a network proxy and its core PWA benefit. A strong answer states it intercepts requests as a proxy and enables offline use via granular caching. Red flag: confusing it with Web Workers or DOM manipulation.

Which Web API offloads expensive work from the main UI thread?
TypeScript & Web APIs2 min read

Which Web API offloads expensive work from the main UI thread?

Cite Web Workers, instantiate new Worker(url), and communicate via postMessage and onmessage.

Programmatically change SPA URL without reload and what is state for?
TypeScript & Web APIs2 min read

Programmatically change SPA URL without reload and what is state for?

This tests History API fluency. Answer: use pushState or replaceState to change the URL silently; the state object is serializable data tied to the history entry, surfaced through popstate on back or forward navigation.

Why access IndexedDB exclusively from a Web Worker?
TypeScript & Web APIs2 min read

Why access IndexedDB exclusively from a Web Worker?

Tests whether you know IndexedDB in workers keeps the main thread free from serialization and transaction overhead, while recognizing that postMessage copying and request-response coordination add real architectural complexity.

How do you query IndexedDB products by price range?
TypeScript & Web APIs2 min read

How do you query IndexedDB products by price range?

Tests IndexedDB indexing and range query APIs. You need a price index created in onupgradeneeded, then IDBKeyRange.bound(50, 100) with index.getAll or openCursor. Red flag: fetching all records and filtering in JavaScript.

How do you add a new index to an existing IndexedDB store?
TypeScript & Web APIs2 min read

How do you add a new index to an existing IndexedDB store?

Tests production schema migration discipline. Bump the integer version in open(), handle onupgradeneeded before onsuccess, use event.oldVersion for incremental changes, and guard against duplicate index creation.

Write an IndexedDB add function with transaction error handling
TypeScript & Web APIs2 min read

Write an IndexedDB add function with transaction error handling

Tests IndexedDB request-transaction lifecycle and event-driven error propagation. Answers open a transaction, call add(), and wire onsuccess/onerror on the request plus onabort/onerror on the transaction. Red flag: ignoring onabort or duplicate-key throws.

Explain IndexedDB transactions and readonly vs readwrite modes
TypeScript & Web APIs2 min read

Explain IndexedDB transactions and readonly vs readwrite modes

Every operation needs a transaction; readonly allows concurrent readers, readwrite is exclusive; they auto-commit when idle.

TypeScript & Web APIs2 min read

Design a type-safe generic localStorage wrapper in TypeScript

Generic getItem<T> returns T|null via JSON.parse, setItem<T> stringifies, and a key-to-type map enforces safety.

What are localStorage's capacity and synchronous blocking limitations?
TypeScript & Web APIs2 min read

What are localStorage's capacity and synchronous blocking limitations?

This tests Web Storage API trade-offs and main-thread blocking. A strong answer notes synchronous calls block the main thread; cites a finite per-origin quota; and names IndexedDB for async needs. Red flag: calling it a database or ignoring UI freezes.

How do you store and retrieve a TypeScript object in localStorage?
TypeScript & Web APIs2 min read

How do you store and retrieve a TypeScript object in localStorage?

This tests your knowledge of Web Storage string constraints and JSON serialization. A strong answer covers JSON.stringify on write, JSON.parse on read, and typing the result with a TypeScript interface.

What is the core difference between localStorage and sessionStorage?
TypeScript & Web APIs2 min read

What is the core difference between localStorage and sessionStorage?

SessionStorage dies with its tab; localStorage survives restarts and shares across tabs. Example: checkout form versus theme preference.

TypeScript & Web APIs2 min read

Write a generic CreateSetters<T> that maps properties to setter methods

This tests TypeScript mapped types with key remapping and template literals. It iterates keyof T, remaps via as set plus Capitalize of string and K, and types values as setter methods. Red flag: manually typing setters or omitting string and K in Capitalize.

TypeScript & Web APIs2 min read

Implement recursive DeepReadonly<T> for nested objects and arrays

Tests recursive mapped types and conditional type narrowing. A strong answer uses a conditional to split arrays into ReadonlyArray, objects into readonly mapped types, and leaves primitives untouched.