Realistic question sets for JavaScript, React, and frontend system design. In the simulator, your answers are evaluated with AI scoring and converted into personalized prep plans.
Frontend interview questions for 0–2 years of experience
Recommended for you
At this level interviewers check fundamentals and whether you can explain them plainly. Expect JavaScript basics, core CSS, one framework, and a small UI to build.
What is the difference between var, let and const?
var is function-scoped and is hoisted with the value undefined. let and const are block-scoped and sit in the temporal dead zone until their declaration runs, so reading them early throws. const stops reassignment, not mutation: you can still push to a const array. Default to const and reach for let only when you must reassign.
A closure is a function that keeps access to the variables of the scope where it was created, even after that scope has returned. It is how you get private state, memoization, and wrappers like debounce or once. The classic bug is a var loop with setTimeout, where every callback sees the final value of the loop variable.
Explain the CSS box model and box-sizing: border-box.
Every element is a box made of content, padding, border and margin. With the default content-box, width covers only the content, so adding padding makes the element wider than you wrote. With border-box, width includes padding and border, which keeps layouts predictable. Most resets apply it to every element.
When its own state changes, when its parent re-renders, or when a context value it reads changes. A re-render is not a DOM update: React compares the new output with the old and commits only the differences. Props being unchanged does not stop a child re-rendering unless it is wrapped in React.memo.
Keys let React match items between renders. Use a stable, unique id. An array index is fine for a static list, but if items can be reordered, inserted or removed, index keys attach component state to the wrong item.
How does async/await work, and how do you handle errors?
async/await is syntax over promises. await pauses that function, not the thread, and the rest of the program keeps running. Wrap awaited calls in try/catch, and remember that Promise.all rejects as soon as one promise rejects, while Promise.allSettled waits for all of them.
Frontend interview questions for 3–5 years of experience
Recommended for you
Here the questions move from definitions to judgment: why something breaks, how you would measure it, and how you would build a real component. Machine coding rounds expect clean, working code with edge cases handled.
Walk me through the JavaScript event loop.
The call stack runs synchronous code. When it is empty, the loop drains the whole microtask queue (promise callbacks, queueMicrotask), then takes one macrotask (setTimeout, I/O, UI events), and the browser may render between tasks. That is why a promise's then callback runs before setTimeout with a 0 delay.
useEffect vs useLayoutEffect, and the common useEffect bugs.
useEffect runs after the browser has painted. useLayoutEffect runs after DOM changes but before paint, which is the place to measure layout without a flicker. The usual bugs are missing dependencies (stale closures), no cleanup (leaks, or a slow earlier fetch overwriting a newer one), and using an effect to compute something you could derive during render.
Measure first with the React Profiler. Then keep state close to where it is used, split components so a change touches less, and use React.memo for expensive pure children. useMemo and useCallback help only when they keep a reference stable for a memoized child or skip a genuinely expensive computation. Virtualize long lists.
What is the difference between debounce and throttle?
Debounce waits until calls stop for N milliseconds, which suits a search input. Throttle lets a call through at most once every N milliseconds, which suits scroll and resize handlers. Be ready to write debounce from scratch: it is a closure holding a timer id that you clear and reset on each call.
How do you improve Core Web Vitals: LCP, INP and CLS?
For LCP, make the main image or heading arrive sooner: size and preload the hero image, render on the server, and use a CDN. For INP, break up long tasks, defer non-critical JavaScript and keep event handlers light. For CLS, reserve space for images, ads and embeds with width and height or aspect-ratio, and do not insert content above what the user is reading.
Debounce the input, cancel stale requests with AbortController or ignore out-of-order responses, and cache results by query. Support keyboard navigation with the combobox ARIA pattern, and handle loading, empty and error states. Highlight the matched text and close the list on Escape or outside click.
Senior rounds test architecture, trade-offs and leadership. Interviewers want your reasoning out loud: what you would choose, what it costs, and how you would know it worked.
How would you manage state in a large application?
Separate server state from UI state. Use a data-fetching cache such as React Query or SWR for server data (deduping, revalidation, retries), keep UI state local by default, and lift it only when components truly share it. Put shareable state such as filters in the URL, and keep any global store small. One store for everything is the usual mistake.
Use cursor-based pagination and an IntersectionObserver sentinel to load the next page. Virtualize the list so the DOM stays small, dedupe items when a refetch overlaps, show skeletons while loading, restore scroll position on back navigation, and offer a Load more button as an accessible fallback. Cover optimistic updates for likes and retry on failure.
Start with route-level splitting, then lazy-load heavy components that are not needed on first paint: editors, charts, modals. Preload on intent, for example on hover. Check the result with a bundle analyzer and watch for request waterfalls, since splitting can make loading slower if chunks load one after another.
When several teams must ship independently at a scale where a single deploy is the bottleneck. The costs are duplicated dependencies, inconsistent UX, runtime integration complexity and slower pages. Often a monorepo with clear module boundaries gives most of the benefit with far less overhead.
Escape output by default (React does this for text; be careful with dangerouslySetInnerHTML and sanitize any HTML you must render), set a Content Security Policy, and keep session tokens in httpOnly, SameSite cookies instead of localStorage. If you use cookie auth, add CSRF protection. Audit third-party scripts and dependencies.
Use the STAR structure. At senior level the story should show that you framed the options, brought people along, weighed trade-offs, handled disagreement, and measured the result afterwards. Name what you would do differently.
What are the most common frontend interview questions?
The most common frontend interview questions cover JavaScript fundamentals (event loop, closures, async/await, prototypes), React (hooks, reconciliation, performance), CSS and layout (flexbox, grid, specificity), machine coding (build a UI component), frontend system design (autocomplete, infinite scroll, a video player) and behavioral questions.
Are these the exact questions asked in real interviews?
No. They are representative of the topics and patterns interviewers use at each level. Exact questions differ by company and change over time, so treat them as patterns to practice, not a list to memorise.
What is a machine coding round in a frontend interview?
A machine coding round is a live session where you build a working UI component or small app from scratch, for example an autocomplete, a Kanban board, a star rating or an infinite scroll list. It tests clean, maintainable code under time pressure. It is common at Indian product companies such as Flipkart, Swiggy, Razorpay and CRED.
How do I prepare for React interview questions?
Focus on hooks (useState, useEffect, useCallback, useMemo, useRef and custom hooks), how re-rendering and reconciliation work, performance (React.memo, lazy loading, code splitting), state management (Context, Redux, Zustand, a data-fetching cache) and component design. Practice by building components from scratch, then get feedback on your code.
What frontend interview questions are asked for 3+ years of experience?
Expect depth in React architecture, performance optimization, TypeScript and a first round of frontend system design, plus behavioral questions about owning features end to end. Machine coding rounds expect production-quality code with error handling and edge cases.
Do frontend interviews include DSA?
It depends on the company. Large product companies often include data structures and algorithms alongside UI work. Many startups and product teams focus on building UI and on JavaScript and React depth. Check the company page for what that company tends to ask.