Skip to content

21 interview questions

Frontend developer interview questions and answers

Frontend interviews test JavaScript fundamentals, a framework such as React, CSS layout and how the browser actually renders a page. Many include a small live build, so expect to write a component while explaining your choices. Strong candidates also talk about accessibility and performance without being asked.

Updated

JavaScript fundamentals

01What is a closure in JavaScript?

What they want to hear: Whether you understand scope well enough to explain bugs and patterns that depend on it.

Answer outline

  1. A closure is a function together with the variables from the scope where it was created; it keeps access to them after that outer function has returned.
  2. Example: function counter() { let n = 0; return () => ++n; } - each call to counter() gives a function with its own private n.
  3. Uses: private state, factories, callbacks and event handlers that remember context.
  4. Classic pitfall: var in a loop shares one variable across callbacks; let creates a new binding per iteration.

02Explain the event loop.

What they want to hear: That you can predict the order of async code and explain why the UI freezes when the main thread is busy.

Answer outline

  1. JavaScript runs on one main thread with a call stack.
  2. Async work (timers, network, events) is handled by the browser, and callbacks are queued when ready.
  3. When the stack is empty, all microtasks (promise callbacks, queueMicrotask) run before the next macrotask (setTimeout, events).
  4. So a resolved promise callback runs before a setTimeout(fn, 0), and long synchronous work blocks rendering.

03What is the difference between var, let and const?

What they want to hear: Basics of scope and hoisting, and whether you write predictable code.

Answer outline

  1. var is function scoped and hoisted with the value undefined.
  2. let and const are block scoped and sit in the temporal dead zone until declared.
  3. const prevents reassignment of the binding, not mutation of an object it points to.
  4. Default to const, use let when you reassign, and avoid var in modern code.

04How does 'this' work in JavaScript?

What they want to hear: A frequent source of bugs; they want to see you reason from how a function is called.

Answer outline

  1. For a regular function, this depends on the call: obj.method() sets it to obj, a plain call gives undefined in strict mode.
  2. call, apply and bind set it explicitly; new sets it to the new object.
  3. Arrow functions have no own this and take it from the surrounding scope.
  4. Example: passing obj.method as a callback loses this unless you bind it or use an arrow function.

05What is the difference between == and ===?

What they want to hear: Awareness of type coercion and a habit of writing code that avoids surprises.

Answer outline

  1. === compares value and type without conversion.
  2. == converts types first, so '0' == 0 and null == undefined are true.
  3. Use === by default; == null is sometimes used deliberately to check for both null and undefined.

06Implement a debounce function.

What they want to hear: A common live task that tests closures, timers and practical understanding of UI events.

Answer outline

  1. Return a new function that keeps a timer id in a closure.
  2. On each call, clearTimeout the previous timer and set a new one for the delay.
  3. When the timer fires, call the original function with the latest arguments and the right this.
  4. Explain the use: search inputs and resize handlers. Contrast with throttle, which runs at most once per interval.

React and state

07What happens when state changes in a React component?

What they want to hear: A correct mental model of rendering, which drives every performance and bug discussion.

Answer outline

  1. Setting state schedules a re-render of that component and, by default, its children.
  2. React calls the component again to produce new elements and compares them with the previous ones.
  3. Only the differences are applied to the DOM.
  4. State updates may be batched, so read the new value in the next render, or use the updater form setX(prev => ...).

08Explain useEffect and its dependency array.

What they want to hear: Whether you use effects for synchronisation with outside systems and avoid the common traps.

Answer outline

  1. useEffect runs after render to sync with something outside React: subscriptions, timers, network, the DOM.
  2. The dependency array lists values the effect reads; it re-runs when any of them change.
  3. Return a cleanup function to unsubscribe or cancel, which runs before the next effect and on unmount.
  4. Avoid effects for values you can compute during render, and do not leave out dependencies to silence the linter.

09Why does React need keys in lists?

What they want to hear: Understanding of reconciliation and a classic bug source.

Answer outline

  1. Keys tell React which item is which between renders.
  2. With stable keys React can move, add or remove items correctly and keep their state.
  3. Using the array index as a key breaks when items are reordered or inserted, mixing up state and inputs.
  4. Use a stable id from the data.

10How do you decide where state should live?

What they want to hear: Architecture judgment: avoiding both prop drilling chaos and a global store for everything.

Answer outline

  1. Keep state as close as possible to where it is used.
  2. Lift it to the nearest common parent when siblings need it.
  3. Use context for values many components read but that change rarely, such as theme or user.
  4. Treat server data separately with a data fetching or caching library, and use a global store only for truly shared client state.

11How do you avoid unnecessary re-renders?

What they want to hear: That you measure first and know which tools actually help.

Answer outline

  1. Measure with the React DevTools profiler before changing anything.
  2. Move state down or split components so fewer parts re-render.
  3. Use memo, useMemo and useCallback where a profile shows a real cost, not everywhere.
  4. For long lists, use virtualisation.

HTML, CSS and accessibility

12Explain the CSS box model.

What they want to hear: Layout basics that explain most sizing bugs.

Answer outline

  1. Each element is content, then padding, then border, then margin.
  2. With box-sizing: content-box, width covers only the content; with border-box it includes padding and border.
  3. Most projects set border-box globally so widths are predictable.
  4. Mention that vertical margins between blocks can collapse.

13When would you use Flexbox and when CSS Grid?

What they want to hear: Practical layout skill and choosing the right tool.

Answer outline

  1. Flexbox lays items out in one dimension, a row or a column, and is great for toolbars and aligning items.
  2. Grid controls two dimensions at once, rows and columns, and suits page layouts and card grids.
  3. They combine well: a grid for the page, flex inside components.

14How do you make a web page accessible?

What they want to hear: Whether accessibility is part of how you build, not an afterthought.

Answer outline

  1. Use semantic HTML first: buttons for actions, links for navigation, labels for inputs, headings in order.
  2. Make everything work with a keyboard, with visible focus.
  3. Provide text alternatives for images and enough colour contrast.
  4. Use ARIA only when native elements cannot express it, and test with a screen reader and automated checks.

15How do you build a responsive layout?

What they want to hear: A mobile-first habit and knowledge of modern CSS tools.

Answer outline

  1. Start with the small screen layout and add complexity with media queries.
  2. Use fluid units, flexible grids and max-width rather than fixed pixel widths.
  3. Serve responsive images with srcset and sizes.
  4. Test on real devices or emulators, including touch targets and text zoom.

Performance and the browser

16How would you improve the loading performance of a slow page?

What they want to hear: A measured approach with knowledge of what actually affects users.

Answer outline

  1. Measure with Lighthouse and real user data, focusing on Core Web Vitals: LCP, INP and CLS.
  2. Reduce JavaScript: code splitting, lazy loading, removing unused dependencies.
  3. Optimise images and fonts: modern formats, correct sizes, preloading the main image.
  4. Use caching and a CDN, and reserve space for content to prevent layout shifts.

17What is the difference between client-side and server-side rendering?

What they want to hear: Whether you understand the trade-offs behind the framework choices your team makes.

Answer outline

  1. Client-side rendering ships JavaScript that builds the page in the browser; simple to host, slower first paint, weaker for SEO.
  2. Server-side rendering sends ready HTML, which shows content sooner, then hydrates for interactivity.
  3. Static generation renders at build time and is fastest when content does not change per request.
  4. Choose by content type: marketing pages static or server rendered, logged-in dashboards often client heavy.

18What is CORS and why does it exist?

What they want to hear: A common integration problem; they want to see you understand the browser security model.

Answer outline

  1. Browsers apply the same-origin policy: scripts cannot read responses from another origin by default.
  2. CORS lets a server allow specific origins through headers such as Access-Control-Allow-Origin.
  3. Some requests trigger a preflight OPTIONS request to check allowed methods and headers.
  4. The fix belongs on the server; disabling it in the browser is not a solution.

Working as a frontend developer

19Tell me about a time you pushed back on a design that would be hard to build or use.

What they want to hear: Collaboration with designers and the ability to propose alternatives instead of just saying no.

Answer outline (STAR)

  1. The design and the concern: cost, performance or accessibility.
  2. How you raised it, ideally with a quick prototype or example.
  3. The compromise you reached with the designer.
  4. The outcome for users and for the relationship.

20Describe a UI bug that was hard to track down.

What they want to hear: Debugging skill in the browser and clear technical storytelling.

Answer outline (STAR)

  1. The symptom and which browsers or devices it affected.
  2. The tools you used: devtools, performance panel, network tab, logging.
  3. The root cause and the fix.
  4. What you added to prevent it, such as a test or a lint rule.

21Tell me about a time you improved a frontend codebase.

What they want to hear: Ownership beyond tickets and the ability to make improvements safely.

Answer outline (STAR)

  1. What was slowing the team down.
  2. The change you proposed and how you got agreement.
  3. How you rolled it out without breaking things.
  4. The measurable result: build time, bundle size, fewer bugs.

How to prepare

  • Be ready to build a small component live, such as a search box with debouncing, a modal or a todo list, and talk while you build.
  • Know JavaScript itself, not only the framework: closures, the event loop, promises, this and prototypes come up often.
  • Mention accessibility and loading states in live tasks before the interviewer asks.
  • Have one project you can open and walk through, explaining how it is structured and why.
  • Revise CSS layout with Flexbox and Grid by building a couple of layouts from scratch without a framework.

Practice these questions out loud with NORDON

Reading answers is not the same as saying them. NORDON's interview practice asks you questions written for the role, listens to your spoken answer and shows you how to make it stronger.

  1. Upload your CV in the Knowledge base, so questions and feedback use your real background.
  2. Open Practice, enter the role (for example frontend developer), paste the job ad if you have it, and choose 3, 5, 8 or 10 questions and the answer language.
  3. Listen to each question and answer out loud, as you would in the room. You can also type an answer.
  4. Get a score from 1 to 10, what worked, what to improve and a stronger answer to rehearse. It uses only what you said and your documents, and leaves a [placeholder] where a fact about you is missing.
  5. Try the question again, or move on. For a dress rehearsal, run a mock call where an interviewer voice asks the questions out loud.

The free plan includes 10 scored practice answers a month and mock calls of up to 10 minutes, no card needed. Paid plans include more practice and mock calls of up to 30 minutes. How practice works

Practice is for preparing. Use live help in a real interview only where the interviewer allows AI assistance, never in an interview, test or assessment whose rules forbid it.

NORDON for job interviews

Preparing for your frontend developer interview

What kind of live coding should I expect in a frontend interview?

Often a small UI task in a browser-based editor, a JavaScript exercise such as implementing debounce or flattening an array, or both. Some companies give a take-home instead. Ask the recruiter so you can practise in a similar setup.

Do I need to know a specific framework?

It depends on the role. Most job ads name one, often React, and you should know it well. Strong JavaScript, HTML and CSS fundamentals still matter more, because they transfer between frameworks.

Should I prepare a portfolio?

It helps. A few live projects with readable code tell an interviewer more than a long list of technologies. Make sure they work on mobile and have no obvious accessibility problems.