Full stack interview essentials
Connect JavaScript, React, APIs, and databases into answers you can defend.
JavaScript & TypeScript
Explore topicScope, closures, async behavior, object identity, and the type system.
What is an execution context and call stack?
An execution context is the information JavaScript uses while running a piece of code, including its variables, scope and this value. The call stack tracks which function is currently running and where execution should return. Each function call adds a context, and returning removes it.
What is scope? What does lexical mean?
Scope is the part of a program where a variable can be accessed. JavaScript uses lexical scope, which means the available outer variables depend on where a function was defined, not where it is later called. The engine searches outward through surrounding scopes when a name is not found locally.
What is the difference between var, let and const?
var, let and const declare variables, but they have different scope and initialization rules. let and const are block-scoped, making it easier to keep a variable inside the code that needs it. const prevents reassignment of the binding; it does not make an object immutable.
What are hoisting and the TDZ (Temporal Dead Zone)?
Hoisting is JavaScript's behavior of processing declarations before executing the code in a scope. Because of this, a function declaration can usually be called before its line appears, while variables behave differently depending on how they are declared.
Are objects passed by reference?
JavaScript passes every argument by value. For an object, the copied value is a reference to that object, so the caller and function can still reach the same underlying object. This explains why changing a property affects the caller, but assigning a new object to the parameter does not.
What is the difference between == and ===?
== is loose equality: it may convert values to compatible types before comparing them. === is strict equality: it compares without that conversion. Strict equality usually makes application checks easier to understand because strings, numbers and booleans are not silently treated as the same value.
What are null, undefined and NaN?
undefined usually means a value has not been supplied, while null is commonly used to mark an intentionally empty value. NaN means a numeric calculation or conversion did not produce a valid number. These are different cases, so an API should not treat them as interchangeable without a clear rule.
What is a closure?
A closure is a function together with access to the variables in the scope where it was created. That access remains available even after the outer function has finished running. Closures are useful for private state, callbacks and functions configured with some remembered value.
How does async JavaScript run?
Asynchronous JavaScript lets a program start work that may finish later without waiting synchronously for the result. A promise represents eventual completion, and async/await provides a readable way to work with promises. The runtime queues continuations and runs them when the current synchronous work has finished and the relevant checkpoints are reached.
Which Promise method should I use?
Promise combinators combine several promises into one result. The correct method depends on whether you need every success, every outcome, the first outcome or the first success. They observe promises; they do not automatically cancel ongoing operations when the combined result settles.
Why does forEach with async cause problems?
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.
What causes a race condition?
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.
React & Next.js
Explore topicRendering, hooks, state ownership, performance, and server boundaries.
When should I use useEffect?
useEffect synchronizes a committed component with something outside React, such as a connection, timer or browser event listener. Its setup runs when relevant dependencies change, and cleanup ends the old synchronization. Effects are not the usual place to compute values already available during rendering.
Why does an effect run twice in development or loop forever?
React Strict Mode performs an extra development-only setup and cleanup cycle for effects to reveal missing cleanup. An infinite effect loop is a different issue, usually caused by updating state that keeps changing an effect dependency. Understanding the trigger helps fix the design rather than masking the behavior.
useRef vs useState?
useState stores a value that participates in the UI, while useRef stores a stable mutable container whose changes do not request rendering. A ref is useful for an imperative handle such as a DOM node or timer ID. It should not replace state for information that the screen must show when it changes.
useMemo vs useCallback?
useMemo caches a calculated value between renders until its dependencies change. useCallback preserves a function reference under the same dependency idea. They can reduce repeated work or unstable props, but memoization is an optimization rather than a correctness guarantee.
When do I use Context, useReducer or a custom hook?
Context shares a value with descendants without passing it through every intermediate component. useReducer organizes state changes through actions and a reducer, while custom hooks extract reusable stateful logic. These tools address distribution, transition structure and reuse respectively; they are not interchangeable state stores.
Node.js, Express & HTTP
Explore topicTrace requests, understand the runtime, and build reliable APIs.
Browse interview questionsMongoDB & Mongoose
Explore topicDocument modeling, aggregation, indexes, and consistency.
How do indexes help, and what do they cost?
An index is an extra data structure that helps the database find matching records without inspecting every document. Reads can become much faster, but inserts, updates and deletes must maintain the relevant indexes. Indexes are most useful when their fields and order match important query patterns.
What index types should I know?
MongoDB offers different index types because equality lookup, array search, text search, uniqueness and expiry have different needs. A compound index orders several fields together, while a partial index includes only documents matching a condition. TTL indexes support eventual cleanup rather than precise scheduling.
When do I need a transaction?
A transaction makes several database operations commit or roll back as a unit. MongoDB already makes single-document writes atomic, so a transaction is mainly needed when one business rule spans multiple documents. A session supplies transaction context; every participating operation must use that context.
SQL & PostgreSQL
Explore topicJoins, window functions, transactions, and query optimization.
What does ACID mean?
ACID describes four properties used to reason about reliable transactions: atomicity, consistency, isolation and durability. Together they address partial changes, preserved rules, concurrent work and persistence after commit. They do not automatically supply correct business rules or the strongest isolation level.
What are isolation levels and read anomalies?
Isolation defines how one transaction can observe and interfere with concurrent transactions. Different levels allow different anomalies to balance correctness, concurrency and retry cost. PostgreSQL uses snapshots under MVCC, but even a stable snapshot does not automatically make every business decision safe against concurrent writes.
Optimistic vs pessimistic locking?
Optimistic locking checks whether data changed before committing an update, often by comparing a version number. Pessimistic locking acquires a database lock before performing a critical change. The first avoids waiting when conflicts are rare; the second coordinates competing writers but can increase waits and deadlocks.
What is a deadlock, and how do I handle it?
A deadlock is a cycle of waiting transactions: each holds a lock another needs to continue. The database detects the cycle and cancels a participant so the others can proceed. Applications must treat that cancellation as a failed transaction and decide whether to retry it.
Which indexes should I know?
An index is a separately maintained structure that makes suitable lookups, joins or ordering operations cheaper. B-tree is a common general-purpose choice, while composite, partial and unique indexes describe field arrangement, row selection and data rules. An index helps only when the planner estimates its use is worthwhile for the query and data.
Is an index scan always faster than a sequential scan?
An index scan follows an index to locate matching rows, while a sequential scan reads the table directly. If a query needs much of a table, following many scattered row locations can cost more than scanning it. PostgreSQL's planner weighs expected row count, I/O and other costs rather than always preferring indexes.
System design
Explore topicArchitecture decisions, distributed systems, and ten design scenarios.
Testing & delivery
Explore topicTesting, Git, containers, CI/CD, and cloud fundamentals.
Browse interview questions