Most frontend developer interview questions are not about your framework. They look like React or Vue questions on the surface. Underneath, they test the platform: why a function sees the variable it sees, why a failed request did not stop the others, why a component you removed is still in memory. Framework knowledge gets you through the first ten minutes. Platform knowledge decides the rest.
Frontend interview questions cluster into five areas:
- JavaScript semantics - scope, closures,
this, coercion - Asynchronous code - promises, async/await, the event loop and cancellation
- The browser - DOM, rendering, memory and performance
- CSS and HTML - layout, the cascade, semantic markup and accessibility
- Security - XSS, Content Security Policy, CORS and cookies
This guide covers what each area asks in a frontend developer interview and how a strong answer is built, then gives a 7-day plan. First, find out where you stand.
Start here: a 5-question self-check
Five questions from squizzu's question bank, one per area, in the order of the sections below. No sign-up: answer, then read the explanation and the in-depth breakdown. A miss is useful information. It tells you which section to read properly rather than skim.
Two of these catch experienced developers. The Promise.all() question does because the wrong answer matches how most people picture promises: as the work itself rather than a handle to its result. The CSP question does because two of the wrong options are things a developer would plausibly try at 6 p.m. on a Friday. If scope fooled you, start with area 1; Promise.all() belongs to area 2, the detached element to area 3, box-sizing to area 4 and CSP to area 5.
What a frontend developer interview looks like in 2026
- Recruiter screen. Your recent projects. Pick ones where you can explain a decision, not just a feature.
- Technical screen. Rapid questions from the five areas, often with a snippet: "what does this print?"
- Coding round. Usually practical: build a component, implement
debounce, render a paginated list from an API, fix a form. Large tech companies may add one data structures round at an easier level than for backend roles. - Frontend system design. From mid-level. An autocomplete, an infinite feed, a data table with 100k rows, a chat window. Component boundaries, state ownership, data fetching, performance.
- Behavioural. A disagreement with design or backend, a performance problem you tracked down.
Area 1: JavaScript interview questions: scope, closures and this
Snippet questions live here. The interviewer shows ten lines and asks what they print. The point is not trivia; each snippet isolates one rule that causes real bugs.
Scope is lexical. A function resolves names in the scope where it was written, not where it was called. Closures follow from that: an inner function keeps access to the variables of the scope it was created in, even after that scope has returned. The classic var in a loop with setTimeout printing the same number three times is the same rule, plus the fact that var is function-scoped and let creates a new binding per iteration.
this is dynamic. In a regular function it depends on how the function is called: as a method, standalone, with new, or through call, apply or bind. Arrow functions have no this of their own and take it from the enclosing scope, which is why they also cannot be used as constructors.
Coercion has rules. == converts operands before comparing, + concatenates as soon as one side is a string, and typeof null is "object" for historical reasons. You do not need to memorise the full table, but you should know where it bites.
Question: What is a closure, and give an example of one causing a bug.
Short answer: A function bundled with references to the variables of the scope it was created in. A common bug is a stale closure: an event handler or effect created once keeps reading the value from that moment, while the variable it should see has moved on.
What the interviewer is testing: Whether you can connect the definition to a symptom. "It works the first time and then stops updating" is a closure problem far more often than a framework bug.
Common follow-up: "How would you write a function that runs at most once?" (A closure holding a called flag and the cached result.)
Area 2: Async JavaScript and the event loop
This is the area where framework experience hides gaps most effectively, because libraries handle the hard parts until the day they don't.
Know the event loop well enough to predict ordering. Synchronous code runs to completion. When the call stack empties, every queued microtask runs (promise callbacks, queueMicrotask), and only then does the next task run (timers, network events, user input). Rendering happens between tasks, which is why a long synchronous loop freezes the page and why an endless chain of microtasks can starve rendering too.
Know the promise combinators and what each does on failure: Promise.all rejects on the first rejection, allSettled waits for every result, race settles with the first to settle, any with the first to fulfil. Then know what none of them do. A promise represents a result; it does not own the work producing it. Cancellation is a separate mechanism, AbortController, and you have to wire it through yourself.
Question: A search box fires a request on every keystroke and sometimes shows results for an older query. Why, and how do you fix it?
Short answer: Responses arrive out of order, so a slow response for "re" can land after a fast one for "react". Abort the previous request when a new one starts, or ignore any response that does not belong to the latest query, and debounce the input so fewer requests start at all.
What the interviewer is testing: Race conditions in UI code. This is one of the most common real bugs in frontend work, and the fix shows whether you think of requests as things that can be stopped.
Common follow-up: "Implement debounce." (A closure over a timer id, cleared and reset on each call. Then: how would you add a leading option?)
Area 3: Browser, DOM and performance questions
Here the interviewer checks that you understand what the browser does with your code after the framework hands it over.
Rendering. Changing layout properties (width, position, font size) forces layout; changing transform or opacity can often be done by the compositor alone. Reading a layout value such as offsetHeight right after writing a style forces the browser to compute layout synchronously, and doing it in a loop causes layout thrashing.
Memory. Garbage collection frees what nothing can reach. Removing an element from the DOM is not the same as freeing it. Listeners that are never removed, caches that only grow, and intervals that outlive their component are the usual leaks, and a heap snapshot in DevTools is how you find them.
Performance metrics. Know Core Web Vitals by name and cause. LCP measures when the main content appears and is usually hurt by large images and render-blocking resources. INP measures responsiveness to input and is hurt by long tasks on the main thread. CLS measures layout shift and is usually caused by images without dimensions and late-loading content.
Question: A page feels sluggish when users type into a filter box. How do you investigate?
Short answer: Record a performance profile while typing, look for long tasks on the main thread, and find what runs on each keystroke. Then make that work cheaper, defer it, or move it off the main thread.
What the interviewer is testing: A method grounded in tools. "Add useMemo" before profiling is the answer they are filtering out.
Common follow-up: "What can a Web Worker do, and what can't it?" (It runs scripts off the main thread but has no DOM access, so it computes and posts results back.)
Area 4: CSS and HTML interview questions
CSS questions are where candidates who learned layout by trial and error get found out. You need the model, not just the property names.
The box model. Content, padding, border and margin, and how box-sizing changes what width means. Margin collapsing between vertical block siblings.
The cascade. Origin and importance first, then specificity, then source order. Know how to compute specificity for a selector and know what does not affect it at all, such as how close an element sits to the rule's target in the DOM tree. Cascade layers (@layer) now sit in that order too.
Layout. Flexbox for one dimension, grid for two, and when each is the wrong tool. Positioning and stacking contexts, because "my z-index: 9999 does nothing" is a stacking-context question.
HTML and accessibility. Use the element that already has the behaviour: a <button> is focusable and responds to Enter and Space; a <div> with a click handler is neither. Label every input. Keep focus visible, and move it into a dialog when one opens. Know when ARIA is needed and that the first rule of ARIA is not to use it when a native element would do.
Question: Why would you choose CSS grid over flexbox?
Short answer: When the layout is two-dimensional and the rows and columns need to line up with each other. Flexbox distributes items along one axis and lets each line size itself; grid defines the tracks first and places items into them.
What the interviewer is testing: Whether you choose layout tools from the shape of the problem rather than habit.
Common follow-up: "How do you make a card grid that fits as many columns as the viewport allows without media queries?" (grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)).)
Area 5: Frontend security questions
Frontend security questions are practical: the interviewer wants to know whether your code would let an attacker run script in your users' browsers.
XSS. Any path that turns untrusted text into HTML is a risk: innerHTML, dangerouslySetInnerHTML, v-html, URLs built into href. Frameworks escape text by default, so XSS in modern apps usually comes through one of those escape hatches. Prefer textContent when you mean text.
Content Security Policy. A response header that tells the browser which scripts may run. A strict policy with nonces or hashes blocks injected inline script even when an XSS bug exists, which is why it counts as defence in depth. It also blocks some patterns developers rely on, and knowing which ones is part of the question.
CORS and cookies. CORS is enforced by the browser to protect users, not by the server to protect itself; a failing CORS request often reached the server anyway. For cookies, know HttpOnly, Secure and SameSite, and why tokens in localStorage are readable by any script that runs on the page.
Question: What is the difference between XSS and CSRF?
Short answer: XSS runs the attacker's script inside your page, with all the access your own script has. CSRF makes the user's browser send a request your site trusts, from another site, using the user's cookies, without running script on your page at all.
What the interviewer is testing: Whether you can map each attack to its defence: output encoding and CSP for XSS, SameSite cookies and anti-CSRF tokens for CSRF.
Common follow-up: "Your CSP blocks a third-party analytics script. How do you allow it without weakening the policy for everything else?"
A 7-day preparation plan
Build one small app with no framework magic you cannot explain: a searchable, paginated list from a public API, with a detail dialog. If you have only two days, spend them on day 2 and day 6. Async bugs dominate live coding, and answering out loud is the skill candidates practise least.
- Day 1: JavaScript semantics. Write ten snippets that each isolate one rule (scope, closures,
this, coercion). Predict the output, then run them. - Day 2: Async. Build the search box. Reproduce the out-of-order response bug on purpose, then fix it with
AbortControllerand a debounce you wrote yourself. - Day 3: The browser. Render 5,000 rows, profile the page, and remove the longest task. Open and close the dialog twenty times and take a heap snapshot.
- Day 4: CSS and HTML. Build the layout with grid and flexbox, no framework classes. Navigate the whole app with only the keyboard and fix what you cannot reach.
- Day 5: Security. Add a strict CSP header to your dev server and fix everything it breaks. Find every place that turns a string into HTML.
- Day 6: Answer out loud. Take each section's questions and answer in under two minutes: definition, mechanism, trade-off, example.
- Day 7: Close the gaps. Return to whatever the self-check and day 6 exposed, and practise one frontend system design prompt end to end.
How ready are you?
Five questions gave you five data points. The rest of the bank works the same way: commit to an answer, then read why it was right or wrong.
Practise JavaScript, CSS and HTML questions on squizzu, with an explanation and an in-depth breakdown on every question.
If your target role is React-heavy, how to prepare for a React interview in 2026 covers the server/client boundary, React 19 primitives and the Compiler-era memoization questions. The CSS quiz and the HTML quiz cover area 4 in more depth.
