Skip to content
tezvyn:

TypeScript & Web APIs

TypeScript, browser APIs, WebAssembly, PWAs

32 bites

Test yourself: Top 30 easy TypeScript & Web APIs interview questionsMultiple choice, with the correct answer and why it is correct on every question. Free, no sign-in.

Easy interview questions in TypeScript & Web APIs, page 2

What is the core difference between localStorage and sessionStorage?
easy2 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.

How do you store and retrieve a TypeScript object in localStorage?
easy2 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.

Programmatically change SPA URL without reload and what is state for?
easy2 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.

Which Web API offloads expensive work from the main UI thread?
easy2 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.

What is a Service Worker's role and key PWA capability?
easy2 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.

How do you programmatically play, pause, and dynamically set a video source?
easy2 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().

Get canvas 2D context and draw a filled circle
easy2 min read

Get canvas 2D context and draw a filled circle

This tests Canvas API coordinates and context acquisition. A strong answer selects the canvas, calls getContext("2d"), uses path functions for circles, sets color style, and fills. A red flag is ignoring the top-left origin or using SVG instead.

Write a TypeScript async/await function that requests webcam access and handles errors
easy2 min read

Write a TypeScript async/await function that requests webcam access and handles errors

This tests async/await error handling for getUserMedia and stream attachment. A good answer uses try/catch, sets video.srcObject, and branches on NotAllowedError and NotFoundError. A red flag is omitting catch or using src instead of srcObject.

easy1 min read

First compilerOptions to set after tsc --init

Enable strict for full type safety, set target and module to match the runtime, and choose outDir/rootDir or moduleResolution; each tightens checks or aligns output.

easy2 min read

What is tsconfig strict, and which sub-flag to relax for legacy?

Tests strict as a master switch and migration pragmatism. Strong answers name strictNullChecks or noImplicitAny as the first to relax in legacy code, trading null-safety for fewer errors. Red flag: disabling strict entirely instead of a targeted sub-flag.

easy2 min read

How do you add TypeScript types for a library without bundled types?

This tests the DefinitelyTyped @types workflow. Install @types/package as a dev dependency via npm or yarn, skipping it when the library already bundles .d.ts files. A red flag is suggesting manual declarations or extra tooling before checking DefinitelyTyped.

easy2 min read

How do you write a minimal dom-utils.d.ts for a JS function?

Tests bridging untyped JavaScript into TypeScript via ambient module declarations. A strong answer declares a module matching the file path and exports the function with a typed signature. Red flag: suggesting rename to .ts or using any.

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles