JavaScript and React: Interview questions for frontend and full-stack roles
Frontend interviews test core JavaScript (scope, closures, async), then React (components, hooks, state), then a few web fundamentals and a small coding task. This kit works for any employer hiring a frontend or full-stack developer.
19 questions · 3 rounds · updated Nov 2026
How the interview works
- JavaScript core: Scope, closures, this, prototypes, async and the event loop.
- React: Components, props and state, hooks, keys, performance.
- Web and practical: Browser storage, CORS, CSS layout, accessibility, a short coding task.
Sample questions
- 01
What is a closure? Give a practical use.
MediumJavaScript
Model answer
What the interviewer checks
The definition plus a real pattern: private state, memoisation or event handlers.
How to answer
A closure is a function bundled with the variables of the scope where it was created. It can still read and update them after that outer function has returned. ```js function makeCounter() { let count = 0; // private: nothing outside can touch it return { inc: () => ++count, get: () => count }; } const c = makeCounter(); c.inc(); c.inc(); c.get(); // 2 ``` Practical uses: private state (as above), memoisation caches, `debounce` and `throttle` (they keep the timer id in a closure), and React hooks, whose callbacks close over props and state. That is also why a stale closure in useEffect reads an old value when the dependency array is wrong.
- 02
console.log('A'); setTimeout(() => console.log('B'), 0); Promise.resolve().then(() => console.log('C')); console.log('D'); What is the output order?
HardJavaScript
- 03
Implement debounce(fn, wait): the returned function runs fn only after it has stopped being called for `wait` ms. Typical use: a search box.
MediumJavaScript
Approach and solution
Approach
Keep the timer id in a closure. Every call clears the pending timer and starts a new one. Preserve `this` and the arguments.
function debounce(fn, wait) { let timer; return function (...args) { clearTimeout(timer); timer = setTimeout(() => fn.apply(this, args), wait); }; } // Usage: fires once, 300 ms after the user stops typing const onInput = debounce((q) => search(q), 300); input.addEventListener("input", (e) => onInput(e.target.value));Complexity: O(1) per call.
Likely follow-ups
- Throttle runs at most once per interval instead, which suits scroll and resize handlers.
16 more questions, members only
- JavaScript core7
- React5
- Web and practical7
Members also get how to answer each question and a preparation plan for this company.
See plans from ₹399Every question and answer is written by Hirecept and the code is run before it is published. How a company runs its process comes from candidate reports and public pages, and companies change it, so treat that part as a guide, not a promise.