JavaScript & React Interview Questions

Published August 18, 2026 · 8 min read

Frontend interviews for freshers split into two halves: core JavaScript (closures, hoisting, how async code actually runs) and React fundamentals (the virtual DOM, hooks, how data flows through components). Interviewers use these to check whether you understand what your code is doing, not just whether you can copy a pattern from a tutorial.

JavaScript Fundamentals You'll Be Asked About

Closures

A closure is a function that remembers the variables from the scope it was created in, even after that outer function has finished running. The classic example is a counter function: an inner function that increments and returns a variable defined in its enclosing function keeps access to that variable across calls, because the closure "closes over" it.

var vs. let vs. const, and hoisting

var is function-scoped and hoisted with its value initialized to undefined. let and const are block-scoped and hoisted too, but land in a "temporal dead zone" — you can't access them before their declaration line, which is why var's quirky behavior mostly disappears once you use let/const. const means the binding can't be reassigned, not that the value itself is immutable — you can still mutate an object or array declared with const.

The event loop, briefly

JavaScript is single-threaded, but async operations don't block it: the call stack runs your synchronous code, and completed async work (like a resolved Promise or a finished setTimeout) gets queued and only runs once the call stack is empty. This is why a resolved Promise's .then() always runs after synchronous code, even with a 0ms delay — that's the one-line answer interviewers are listening for.

Common React Interview Questions

What is the virtual DOM, and why does it help? It's an in-memory representation of the actual DOM. When state changes, React builds a new virtual DOM tree, diffs it against the previous one, and only applies the minimal set of real DOM updates needed — real DOM operations are expensive, so batching and minimizing them is the whole point.

useState vs. useEffect. useState gives a component local state that persists across re-renders. useEffect runs side effects (data fetching, subscriptions, manual DOM changes) after render, and re-runs when its dependency array changes — an empty array means "run once on mount."

Controlled vs. uncontrolled components. A controlled component's value is driven entirely by React state (via value and onChange) — React is the single source of truth. An uncontrolled component lets the DOM manage its own state internally, and you read it out via a ref when needed.

Props vs. state. Props are passed into a component from its parent and are read-only from the child's perspective. State is owned and managed by the component itself, and changing it triggers a re-render.

A Question You Should Expect

"Walk me through what happens when you call setState (or a state setter from useState)." A strong answer covers: React schedules a re-render rather than updating immediately, multiple state updates in the same event handler are typically batched into one re-render, and the component function re-runs with the new state value on the next render pass.

How to Prepare

Build something small end-to-end — a to-do list or a simple form with validation — since explaining decisions from your own code lands far better than reciting definitions. If you're prepping for a full-stack role, pair this with our Node.js interview questions guide. Practice talking through these concepts out loud with a live-scored AI Mock Interview, or drill core JS/React questions daily with Flash Practice.

Frequently Asked Questions

What JavaScript concepts do interviewers focus on most? Closures, how hoisting works with var/let/const, and the event loop — specifically why a resolved Promise's .then() always runs after synchronous code.

What is the virtual DOM in React and why does it matter? It's an in-memory representation of the real DOM. React diffs a new virtual DOM tree against the previous one and applies only the minimal real DOM updates needed, since real DOM operations are expensive.

What's the difference between useState and useEffect? useState gives a component local state that persists across re-renders. useEffect runs side effects like data fetching after render and re-runs when its dependency array changes.

What's the difference between controlled and uncontrolled components? A controlled component's value is driven entirely by React state via value and onChange. An uncontrolled component lets the DOM manage its own state internally, read out via a ref when needed.