Interview preparation
UNDERSTAND. EXPLAIN. REPEAT.

Question library

Explained questions for the decisions developers make.

Filters
660 questions

Why does forEach with async cause problems?

JavaScript & TypeScript·Async JavaScript

forEach calls a callback for each array item but ignores the values returned by those callbacks. An async callback returns a promise, so forEach does not wait for its completion or collect its rejection. Choose a loop or a promise combinator based on whether the operations depend on each other.

Intermediate2 min read

What causes a race condition?

JavaScript & TypeScript·Async JavaScript

A race condition happens when the result depends on the timing of operations that access shared state. JavaScript can have races even on one execution thread because asynchronous work pauses and lets other requests run between a read and a write. Databases and other processes can also update the same data concurrently.

Intermediate2 min read

Is spread a deep copy?

JavaScript & TypeScript·Functions & objects

Spread syntax creates a new outer object or array by copying its enumerable contents. It is a shallow copy, so nested objects are still shared references. This matters when updating React state or copying request data that another part of the application may modify.

Intermediate2 min read

Debounce vs throttle: what is the difference?

JavaScript & TypeScript·Functions & objects

Debouncing and throttling control how frequently a function runs when events arrive repeatedly. Debouncing waits for a quiet period, while throttling limits execution frequency during continued activity. They reduce unnecessary work but introduce different delays and must match the user experience.

Intermediate2 min read

CommonJS vs ES Modules: what is the difference?

JavaScript & TypeScript·Runtime & modules

CommonJS and ES Modules are two systems for dividing JavaScript code into reusable modules. CommonJS uses runtime require calls, while ES Modules provide standard import and export declarations with a statically described dependency structure. Their loading and interoperability rules depend on the runtime and file configuration.

Intermediate2 min read

What are streams, buffers and EventEmitter?

JavaScript & TypeScript·Runtime & modules

A buffer is a container for raw bytes, while a stream processes a sequence of data in chunks. EventEmitter is a mechanism for registering listeners and notifying them when an event occurs. These tools work together in Node networking and file handling, where data can arrive gradually.

Intermediate2 min read

How do garbage collection and memory leaks work?

JavaScript & TypeScript·Runtime & modules

Garbage collection automatically reclaims memory that can no longer be reached by running code. A memory leak happens when the program keeps a reference to data it no longer needs, so the collector must treat that data as still usable. Increasing the heap limit may delay failure but does not remove the unwanted references.

Intermediate2 min read

Interface vs type: which should I use?

JavaScript & TypeScript·TypeScript

Interfaces and type aliases both describe types that TypeScript checks before runtime. An interface is mainly used for object contracts, while a type alias can name object shapes, unions, tuples and other type expressions. Choosing between them is mostly about the shape being modeled and whether declaration merging is needed.

Intermediate2 min read

What are generics and utility types?

JavaScript & TypeScript·TypeScript

Generics let a function, class or type work with different types while preserving relationships between inputs and outputs. Utility types transform existing types so the same fields do not need to be manually repeated. This reduces duplication without throwing away type information through any.

Intermediate2 min read

What are union, intersection, keyof and typeof?

JavaScript & TypeScript·TypeScript

A union allows a value to match one of several types, while an intersection requires it to satisfy all included types. keyof extracts property names from a type, and TypeScript's type-position typeof derives a type from a value declaration. Together they help express safe property access and reusable contracts.

Intermediate2 min read

What are unknown, any and never?

JavaScript & TypeScript·TypeScript

any allows operations without normal type checking, while unknown accepts any value but requires checks before use. never represents a situation where no value is possible, such as the result of a function that always throws. These types describe different levels of knowledge and should not be used interchangeably.

Intermediate2 min read

How do narrowing and type guards work?

JavaScript & TypeScript·TypeScript

Narrowing is TypeScript's process of reducing a broad type to a more specific type based on control flow and checks. A type guard is a check that gives the compiler evidence about a value, such as typeof, in or a custom predicate. Correct guards help application code safely use data that starts out uncertain.

Intermediate2 min read

What are mapped types, conditional types and decorators?

JavaScript & TypeScript·TypeScript

Mapped types build a new type by visiting the keys of another type, and conditional types choose a type based on a type relationship. Decorators are different: they run as part of JavaScript class definition and can add metadata or change behavior. Type transformations disappear during compilation, while decorator code can affect runtime behavior.

Intermediate2 min read

What is the output here?

JavaScript & TypeScript·Output prediction

Output prediction requires following the order in which synchronous code and queued callbacks can execute. This example combines the current script, a promise microtask and a timer callback. A zero-delay timer becomes eligible later; it does not interrupt the running script.

Intermediate2 min read

Why does a var loop print 3 three times?

JavaScript & TypeScript·Output prediction

The var loop creates one shared function-scoped binding for i. Every callback closes over that same binding, and the loop has already set it to 3 before the timer callbacks run. Using let in the loop header creates a separate binding for each iteration.

Intermediate2 min read

How can Node handle many requests with one JavaScript thread?

Node.js, Express & HTTP·Node internals

Node.js is a JavaScript runtime designed to handle many operations that spend time waiting for I/O. It lets the operating system and supporting runtime facilities wait for work, then runs ready JavaScript callbacks on an event-loop thread. This makes one process useful for many concurrent connections without one JavaScript thread per request.

Intermediate2 min read

What do V8, libuv and the thread pool do?

Node.js, Express & HTTP·Node internals

V8 is the engine that executes JavaScript, while libuv provides the event loop and cross-platform I/O support. The libuv thread pool runs certain operations that would otherwise block, such as many file-system calls. These are separate roles: V8 does not itself manage every network request, and not every async call uses a pool thread.

Intermediate2 min read

What are the main event-loop phases?

Node.js, Express & HTTP·Node internals

The event loop is the scheduling mechanism that decides when ready callbacks can run. Node organizes several categories of callbacks into phases, with separate processing for promise microtasks and next-tick callbacks. A timer delay is a minimum waiting threshold, not a promise of an exact execution time.

Intermediate2 min read

Difficulty is an editorial estimate. Completion means you chose to mark a question as understood.