Blog7 min read

Senior Frontend Interview Questions: What Changes at Senior Level (With Answers)

On this page33 sections

Senior Frontend Interview Questions: What Changes at Senior Level (With Answers)

Senior frontend interviews ask many of the same questions as mid-level ones: closures, React rendering, debounce. The difference is what counts as a good answer. A mid-level answer explains how something works. A senior answer explains when it breaks, what it costs, and what you’d choose instead, usually with an example from your own work.

Interviewers at senior level are looking for:

  • Depth under follow-ups. The first answer is easy; the third “why?” is the real question.
  • Trade-offs. “It depends” followed by what it depends on.
  • Production experience. Debugging, migrations, incidents, rollouts.
  • Influence. How you raise the bar for the team, not just your own code.

Below are 25 questions grouped by area, with what a senior-level answer includes.

JavaScript and async

1. How do you prevent race conditions when fetching data in a UI?

Mid-level answer: “use async/await“. Senior answer: identify the race (responses arrive out of order and stale data overwrites fresh), then pick a fix and explain the trade-off.

// Option A: cancel the previous request (saves bandwidth, needs AbortController support end to end)
let controller;
async function load(query) {
  controller?.abort();
  controller = new AbortController();
  const res = await fetch(`/search?q=${encodeURIComponent(query)}`, { signal: controller.signal });
  return res.json();
}

// Option B: ignore stale responses (works with any promise, but the request still completes)
let latest = 0;
async function loadIgnoringStale(query, render) {
  const id = ++latest;
  const data = await fetchSomething(query);
  if (id === latest) render(data);
}

Mention that in React, the effect cleanup is the natural place for either, and that libraries like TanStack Query handle this through query keys.

2. Implement a concurrency-limited mapAsync.

async function mapAsync(items, limit, fn) {
  const results = new Array(items.length);
  let next = 0;

  async function worker() {
    while (next < items.length) {
      const i = next++;
      results[i] = await fn(items[i], i);
    }
  }

  await Promise.all(Array.from({ length: Math.min(limit, items.length) }, worker));
  return results;
}

Follow-ups to expect: what happens when one task rejects (here, Promise.all rejects but other workers keep running; discuss allSettled or an abort signal), and why next++ is safe (JavaScript runs one piece of code at a time, so there’s no data race).

3. Microtasks vs macrotasks: when does it matter in real code?

Beyond ordering puzzles: a long chain of microtasks can starve rendering, because the browser can’t paint until the microtask queue is empty. Senior answers mention queueMicrotask for batching, why await in a tight loop can still block paint, and using scheduler.yield() or setTimeout to break up long tasks.

4. How would you find a memory leak in a single-page app?

Process: reproduce with a repeatable action (open and close a modal 20 times), take heap snapshots in Chrome DevTools before and after, compare retained objects, look for detached DOM nodes. Common causes: listeners not removed, intervals not cleared, closures captured in module-level caches, subscriptions in effects without cleanup.

5. What’s the difference between structuredClone, JSON.parse(JSON.stringify()) and a hand-written deep clone?

structuredClone handles Map, Set, Date, typed arrays and circular references, but throws on functions and DOM nodes. The JSON round-trip drops undefined, functions and Map/Set, and turns Date into strings. A hand-written clone is only worth it when you need custom behaviour, such as preserving class prototypes.

React

6. Why does this component re-render, and how would you stop it?

function Parent() {
  const [count, setCount] = useState(0);
  const options = { theme: 'dark' };          // new object every render
  return (
    <>
      <button onClick={() => setCount(c => c + 1)}>{count}</button>
      <ExpensiveChild options={options} />
    </>
  );
}
const ExpensiveChild = React.memo(function ExpensiveChild({ options }) { /* ... */ });

React.memo does nothing here because options is a new reference on every render. Fixes, in order of preference: move the constant out of the component; useMemo it if it depends on props; or restructure so the state lives lower (move count into its own component). A senior answer also asks whether the re-render matters at all, and checks with the React Profiler before adding memoisation.

7. When would you not use Context for state?

Context re-renders every consumer when its value changes. That’s fine for low-frequency values (theme, locale, current user), bad for high-frequency ones (form input, cursor position). Options: split contexts, pass a stable store and subscribe with useSyncExternalStore, or use a store library with selectors. See avoiding Context re-renders.

8. Server state vs client state: how do you separate them?

Server state (fetched data) needs caching, deduplication, invalidation and refetching. Client state (UI toggles, form drafts) doesn’t. Mixing them in one global store leads to hand-rolled cache invalidation. A senior answer names a concrete split, such as TanStack Query or RTK Query for server state and local state or Zustand for client state, and explains the migration path from a Redux-everything codebase.

9. How would you migrate a large app from class components or an old router without a freeze?

Strangler pattern: new code uses the new approach, old code is migrated opportunistically, with an adapter layer between them. Add a lint rule to stop new usage of the old pattern. Track progress with a metric (files remaining). Ship behind route-level flags. Interviewers want to hear about sequencing and risk, not syntax.

10. What do Suspense and transitions solve?

startTransition marks an update as non-urgent so typing stays responsive while a heavy list re-renders. Suspense lets you declare loading boundaries instead of threading isLoading through props. Know their limits: Suspense for data needs a framework or library that supports it.

Performance

11. A page’s INP is poor. Walk me through how you’d fix it.

Measure first: field data (CrUX, your RUM tool) to find which interactions are slow, then the DevTools Performance panel to break the interaction into input delay, processing time and presentation delay. Fixes depend on which part is slow: break up long tasks, defer non-urgent work, reduce re-render scope, avoid layout thrashing. Our INP debugging guide walks through a React example.

12. How do you keep a bundle from growing over time?

Route-level code splitting, a bundle-size budget enforced in CI, import() for heavy, rarely used features, auditing dependencies (a date library can add more than your app code), and tree-shakeable imports. A senior answer includes the process: budgets, owners, and alerting, not just the techniques.

13. Render a list of 100,000 rows.

Virtualise: render only the visible rows plus a buffer, with a spacer for total height. Discuss variable row heights (measure and cache), keyboard navigation and screen readers (virtualised rows aren’t in the DOM, so manage aria-rowcount and aria-rowindex), and when pagination is the better product answer.

14. Explain the critical rendering path and one change that improved it in a project you worked on.

The theory is table stakes. The second half is the senior signal: a specific metric, what you changed, and the before and after.

Architecture and system design

15. Design the frontend for a collaborative document editor.

Use a structure such as RADIO. Senior depth: conflict resolution (operational transforms vs CRDTs and their trade-offs), presence, offline edits, undo per user, and rendering large documents. See the full frontend system design handbook.

16. Monorepo or polyrepo for a frontend platform with 10 teams?

There’s no single right answer. Monorepos give atomic changes and shared tooling but need investment in build caching and ownership boundaries. Polyrepos give team autonomy but make cross-cutting changes slow. Say which you’d choose for the stated context and what would change your mind.

17. When are micro-frontends worth it?

When independent deployment across teams is a real bottleneck, not as a default. Costs: duplicated dependencies, inconsistent UX, cross-app state and routing complexity. Mention lighter alternatives, such as a shared component library with clear ownership, or module federation for specific boundaries.

18. How would you design a design system that 20 teams actually adopt?

Tokens first (colour, spacing, type), accessible primitives, documentation with live examples, versioning and codemods for breaking changes, and an adoption metric. The hard part is governance: who can add components and how you deprecate.

19. How do you roll out a risky frontend change?

Feature flags, a percentage rollout, monitoring (error rate, Core Web Vitals, business metrics) with a clear rollback trigger, and a kill switch that doesn’t need a deploy.

Security and reliability

20. How do you prevent XSS in a React app?

React escapes text content by default. The risks are dangerouslySetInnerHTML, href values like javascript: URLs, third-party scripts, and server-rendered HTML. Defences: sanitise any HTML you must render (an allowlist sanitiser), validate URL schemes, a strict Content Security Policy, and Trusted Types where supported.

21. Where should auth tokens live in the browser?

httpOnly, Secure, SameSite cookies keep tokens away from JavaScript, so XSS can’t read them, but you need CSRF protection. localStorage is readable by any script on the page. Discuss short-lived access tokens with refresh rotation, and what changes for cross-domain APIs.

22. How do you know your frontend is broken in production before users tell you?

Error tracking with source maps and release tagging, RUM for performance, synthetic checks on critical flows, and alerts on error-rate changes per release, not raw counts.

Leadership and behavioural

23. Tell me about a technical decision you pushed for that others disagreed with.

Use STAR, but spend most of the time on how you built agreement: the data you gathered, the prototype you built, the concerns you addressed. If the decision turned out wrong, say what you learned. That’s a strong answer, not a weak one. See leading without formal authority.

24. How do you raise code quality across a team without becoming a bottleneck?

Automate what you can (lint rules, type checks, tests in CI), write down conventions once, use code review to teach rather than gatekeep, and grow other reviewers. A strong answer has an example with an outcome.

25. What would you do in your first 90 days here?

Listen and learn the system, find one high-value, low-risk improvement to ship early, build relationships with product and design, and propose a larger plan only once you understand the constraints.

How to prepare for a senior frontend loop

  1. Prepare five stories from your work, each covering a technical decision, a failure, a conflict, a mentoring moment and a measurable improvement. Reuse them across questions.
  2. Practise follow-ups. For each question above, have a friend ask “why?” three times.
  3. Do timed system design. Two or three full 45-minute mocks matter more than reading ten designs.
  4. Keep coding sharp. Senior loops still include a practical UI or JavaScript coding round. Our coding questions cover the common ones.
  5. Research the company. Each company guide lists the rounds and what members were asked.

FAQ

Do senior frontend interviews include LeetCode?
Some do, usually one round at medium difficulty, especially at larger tech companies. Most of the loop is frontend-specific: practical UI coding, JavaScript utilities, system design and behavioural.

How is a staff frontend interview different from senior?
Staff loops weigh scope and influence more heavily: cross-team architecture, technical strategy, and examples of changing how an organisation builds software.

How many years of experience is “senior”?
Titles vary by company. Interviewers care more about the scope you’ve owned than years: did you lead projects end to end, and did other engineers get better because of you?