Ace Your Frontend Developer Interview
Master the questions hiring managers love and showcase your front‑end expertise with confidence.
- Cover core HTML, CSS, and JavaScript concepts
- Deep dive into modern frameworks like React
- Focus on performance, accessibility, and testing
- Include behavioral questions to demonstrate teamwork
- Offer a timed practice pack for realistic rehearsal
Core Frontend Knowledge
While building a product landing page, the layout looked misaligned across browsers.
Ensure each component’s dimensions and spacing were consistent.
Described the box model—content, padding, border, margin—and showed how adjusting padding and margin changes spacing without altering content size. Demonstrated using box-sizing:border-box to include padding/border in width calculations.
The layout rendered consistently, reducing cross‑browser bugs and speeding up the QA cycle.
- How would you reset default browser styles?
- When might you prefer box-sizing:content-box?
- Accurate terminology
- Clear explanation of each layer
- Practical CSS examples
- Understanding of cross‑browser impact
- Confusing margin with padding
- Ignoring border in calculations
- Define content, padding, border, margin order
- Explain how width/height calculations differ with box-sizing
- Show practical CSS snippets (box-sizing:border-box)
- Highlight impact on layout consistency
A design required a navigation menu where items needed to sit side‑by‑side but also respect width constraints.
Choose the appropriate display type for each element.
Explained that block elements start on a new line and take full width, inline elements flow within text without width/height control, and inline‑block combines inline flow with block‑level box properties, allowing width/height settings while staying on the same line.
Implemented the menu using inline‑block, achieving the desired layout without extra floats.
- When would you use display:flex instead of inline‑block?
- Clear distinction of each display type
- Correct examples of use cases
- Mention of layout implications
- Stating that inline elements can have width/height
- Block: new line, full‑width, respects top/bottom margins
- Inline: flows with text, no width/height control
- Inline‑block: sits inline but accepts width/height, vertical‑margin/padding
JavaScript Deep Dive
A dynamic list of items was being added and removed frequently, each requiring a click handler.
Implement click handling efficiently without attaching listeners to every new element.
Described event delegation: attaching a single listener to a common ancestor, using event.target to identify the actual clicked element, and leveraging bubbling. Highlighted benefits like reduced memory usage and automatic handling of future elements.
Reduced the number of listeners from dozens to one, improving performance and simplifying code maintenance.
- How would you stop propagation if needed?
- Accurate description of bubbling
- Correct code syntax
- Clear articulation of benefits
- Suggesting delegation for non‑bubbling events like focus without proper handling
- Define event bubbling and capturing
- Explain attaching listener to parent
- Show code example using e.target
- List benefits: performance, dynamic elements, easier cleanup
Refactoring legacy code to modern standards required updating variable declarations.
Explain scope, hoisting, and mutability differences to the team.
Outlined that var is function‑scoped and hoisted with initialization to undefined, let and const are block‑scoped, let is mutable while const creates a read‑only binding. Mentioned temporal dead zone for let/const and that const objects can still have mutable properties.
Team adopted let/const appropriately, eliminating accidental global leaks and improving code readability.
- Can const be reassigned when holding an object?
- Correct scope explanation
- Hoisting behavior
- Mutability details
- Claiming const makes the value immutable in all cases
- var: function scope, hoisted, can be redeclared
- let: block scope, not hoisted (TDZ), mutable
- const: block scope, not hoisted (TDZ), immutable binding
React Practical
A component needed to fetch data after mounting and update state, but it kept re‑rendering endlessly.
Implement data fetching with useEffect without causing an infinite loop.
Explained that useEffect runs after render and can depend on a dependency array. Showed that omitting the array or including a state variable that is updated inside the effect creates a loop. Recommended providing an empty array for one‑time fetch or listing only stable dependencies, and using cleanup functions when needed.
Data fetched once on mount, UI rendered correctly, and performance issues were resolved.
- When would you need a cleanup function in useEffect?
- Clear explanation of dependencies
- Correct example code
- Understanding of cleanup
- Suggesting useEffect without dependencies for data fetch
- Purpose: side‑effects after render (data fetch, subscriptions)
- Dependency array controls when effect runs
- Infinite loop cause: effect updates a dependency
- Avoidance: empty array for mount‑only, or memoized deps
A dashboard displayed a table with thousands of rows, causing UI lag during scrolling.
Improve rendering performance while preserving functionality.
Recommended using windowing libraries like react-window or react-virtualized to render only visible rows, memoizing row components with React.memo, and ensuring stable keys. Also suggested avoiding inline functions/objects in props and leveraging useCallback for event handlers.
Scrolling became smooth, render time dropped dramatically, and the app remained responsive on low‑end devices.
- What are the trade‑offs of using virtualization?
- Knowledge of virtualization libraries
- Understanding of memoization
- Practical code snippets
- Suggesting to render all items and rely on CSS overflow
- Introduce windowing/virtualization
- Memoize row components
- Stable keys and avoid inline props
- useCallback/useMemo for handlers
Performance & Accessibility
A marketing site had a high bounce rate due to slow initial load.
Identify and implement performance improvements.
Discussed critical rendering path optimization: minify and bundle assets, use code‑splitting with dynamic import, defer non‑critical CSS, lazy‑load images with srcset, enable HTTP/2, and leverage browser caching. Also mentioned measuring with Lighthouse and monitoring with Web Vitals.
First Contentful Paint dropped from 4.2 s to 1.8 s, improving user engagement and SEO scores.
- How do you measure the impact of a performance change?
- Comprehensive list of techniques
- Reference to tooling (Lighthouse, Web Vitals)
- Prioritization based on impact
- Ignoring image optimization
- Asset minification & bundling
- Code‑splitting & lazy loading
- Critical CSS inlined, non‑critical deferred
- Responsive images (srcset, sizes)
- Caching & HTTP/2
A single‑page app needed to be usable by screen‑reader users.
Integrate ARIA attributes to convey UI semantics.
Defined ARIA (Accessible Rich Internet Applications) as a set of attributes that expose UI component roles, states, and properties to assistive technologies. Gave examples: role="button" for div acting as button, aria‑expanded for collapsible sections, aria‑live for dynamic content. Emphasized using native HTML elements first and adding ARIA only when necessary.
Screen‑reader testing showed correct navigation and state announcements, achieving WCAG AA compliance.
- What are the risks of overusing ARIA?
- Accurate definition
- Practical examples
- Best‑practice emphasis
- Suggesting ARIA replace all native semantics
- What ARIA stands for
- When to use ARIA vs native elements
- Common roles (button, navigation, dialog)
- State attributes (aria‑pressed, aria‑expanded)
- Live region attributes
Behavioral
During a sprint review, the product manager pointed out that my component’s color contrast didn’t meet accessibility standards.
Address the feedback, improve the component, and prevent future issues.
Acknowledged the concern, consulted the design system for approved contrast ratios, updated the CSS, added automated contrast testing with axe-core in the CI pipeline, and documented the change in the component library’s README.
The component passed the next accessibility audit, and the team adopted the new testing step, reducing similar issues by 70%.
- How do you ensure feedback loops remain constructive?
- Demonstrates humility
- Concrete actions taken
- Focus on process improvement
- Blaming others or dismissing feedback
- Acknowledge feedback promptly
- Identify root cause (contrast ratios)
- Implement fix and add automated test
- Document and share learning
The design team delivered a high‑fidelity animation for the homepage hero that required heavy SVG filters and large video assets.
Deliver a visually appealing experience without exceeding the 2 MB initial load budget.
Collaborated with designers to simplify the animation, replaced the video with a lightweight Lottie JSON animation, used CSS will‑change and transform for smoother GPU rendering, and implemented lazy loading for the hero assets. Conducted performance testing to ensure the load time stayed under the target.
The final hero loaded in 1.6 s, retained the intended visual impact, and received positive stakeholder feedback while staying within performance budgets.
- What tools do you use to profile animation performance?
- Collaboration with design
- Technical trade‑off justification
- Quantifiable performance outcome
- Compromising design without justification
- Identify performance constraints
- Propose alternative implementation (Lottie, CSS animation)
- Collaborate on design simplification
- Measure impact with performance tools
- HTML5
- CSS3
- JavaScript
- React
- Responsive Design
- Cross-browser Compatibility
- Performance Optimization
- Accessibility
- Unit Testing
- Git