tezvyn:

🌐Frontend Dev

Frontend web development and UI engineering

498 bites

TypeScript & Web APIs30 sec 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.

TypeScript & Web APIs30 sec 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.

TypeScript & Web APIs30 sec 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.

TypeScript & Web APIs30 sec read

Explain IndexedDB transactions and readonly vs readwrite modes

WHAT IT TESTS: Understanding of IndexedDB's transactional model and concurrency. ANSWER OUTLINE: Every operation needs a transaction; readonly allows concurrent readers, readwrite is exclusive; they auto-commit when idle.

TypeScript & Web APIs30 sec 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.

TypeScript & Web APIs30 sec 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.

TypeScript & Web APIs30 sec read

What is the core difference between localStorage and sessionStorage?

WHAT IT TESTS: Tab isolation versus origin-wide persistence. ANSWER OUTLINE: sessionStorage dies with its tab; localStorage survives restarts and shares across tabs. Example: checkout form versus theme preference. RED FLAG: Claiming persistence time differs.

TypeScript & Web APIs30 sec read

Download a large file via fetch and track ReadableStream progress

It tests streaming I/O and backpressure beyond Promise-based fetch. Acquire a reader from response.body, loop read() until done, sum chunk lengths against Content-Length, and emit progress.

TypeScript & Web APIs30 sec read

When does fetch trigger a CORS preflight, and what POST is complex?

Tests whether you know the simple-request boundary. A strong answer names the three safe POST content-types and gives a cross-origin POST with application/json plus a custom header like Authorization.

TypeScript & Web APIs30 sec read

How do you cancel pending fetches using AbortController?

WHAT IT TESTS: Async cancellation and race-condition prevention in UI streams. ANSWER OUTLINE: Keep one AbortController, abort before each fetch, pass its signal, and swallow AbortError. RED FLAG: Forgetting prior abort or leaving rejections uncaught.

TypeScript & Web APIs30 sec read

Create a generic fetchJson wrapper with typed response and error handling

WHAT IT TESTS: marrying TypeScript generics to fetch for typed responses and runtime error handling. ANSWER OUTLINE: generic T parameter, optional RequestInit, throw if !res.ok, return res.json() as Promise<T>. RED FLAG: using any or omitting the ok check.

TypeScript & Web APIs30 sec read

How do you include a JWT in a fetch request?

Tests knowledge of the fetch options object and Bearer scheme syntax. A strong answer sets headers: { Authorization: Bearer <token> } as the second argument and notes fetch does not auto-attach tokens. Red flag: omitting Bearer or hardcoding secrets.

TypeScript & Web APIs30 sec read

Write a typed async fetchUser with error handling

Tests promise-based fetch plus TypeScript return-type contracts. A strong answer checks response.ok before response.json() and types the return as Promise<User>. A red flag is swallowing 4xx/5xx errors silently.

TypeScript & Web APIs30 sec read

Write a createUser function that POSTs JSON via fetch

WHAT IT TESTS: precise fetch configuration for JSON POST requests. A strong answer names method POST, headers Content-Type application/json, and body JSON.stringify(data) with return typing. Red flag: passing the raw object as body or omitting headers.

TypeScript & Web APIs30 sec read

How would you modify fetch to handle HTTP error statuses?

WHAT IT TESTS: awareness that fetch resolves on HTTP errors and needs manual status checking. ANSWER OUTLINE: verify response.ok in then and throw if false, then catch network failures separately.

TypeScript & Web APIs30 sec read

Write a fetch call and log JSON from the Response

This tests async HTTP literacy and fetch's two-stage promise resolution. A strong answer awaits fetch, then awaits response.json(), logs result, and notes fetch does not throw on 4xx/5xx.

TypeScript & Web APIs30 sec read

Implement inSequence(tasks) to execute promise-returning functions sequentially

Tests async/await control flow versus Promise.all parallelism. A strong answer uses a for-of loop with await inside an async function, accumulates results in order, and stops cleanly on rejection. Red flag: suggesting Promise.all or forEach with await.

TypeScript & Web APIs30 sec read

How would you prevent search-as-you-type race conditions with AbortController?

WHAT IT TESTS: Canceling stale fetches to keep the UI consistent. ANSWER OUTLINE: Abort the previous request before each new keystroke, pass the fresh signal into fetch, and ignore the AbortError.

TypeScript & Web APIs30 sec read

How do you type an async function return in TypeScript?

This tests if you know async functions always return Promise<T>. A great answer: annotate Promise<User>, return User from the body, and note TypeScript implicitly wraps it. A red flag is omitting Promise and typing the return as just User.

TypeScript & Web APIs30 sec read

How do you fetch from three APIs using Promise.all versus allSettled?

WHAT IT TESTS: Promise concurrency and failure isolation. ANSWER OUTLINE: Promise.all parallelizes but rejects on first failure. allSettled returns every outcome with status, value, and reason. RED FLAG: Wrapping each call in try-catch to imitate allSettled.