frontend-interview-questions

1. How do you conceptualize the HTML Document Object Model (DOM) and its relationship to React’s Virtual DOM?

The DOM is the browser’s live tree representation of the HTML document. Manipulating it directly is expensive due to reflows/repaints.

React introduces the Virtual DOM (VDOM) as a lightweight in-memory representation of the DOM. On state change:

useState triggers re-render  VDOM diff  minimal DOM updates

This model improves performance and enables declarative UIs.


2. What’s your mental model for structuring semantic HTML in a component-based framework like React?

Semantics should guide structure, even within components. I map roles and intent to proper tags (<nav>, <main>, <section>, <article>).

Example:

function BlogPost({ title, content }) {
  return (
    <article>
      <h2>{title}</h2>
      <section>{content}</section>
    </article>
  );
}

I avoid div soup by treating components as semantic wrappers and using HTML5 tags when possible. This improves accessibility and SEO.


3. How do you think about the interplay between HTML attributes (e.g., data-*, aria-*) and React props?

React treats standard HTML attributes and special-purpose ones (aria-*, data-*) as props passed down to the DOM node .

<button aria-label="Close" data-testid="close-btn">
  X
</button>


4. How would you design an HTML structure to support a complex, nested UI (e.g., a multi-level navigation menu) while keeping it maintainable?

Approach:

function NavItem({ label, children }) {
  return (
    <li>
      {label}
      {children && <ul>{children.map(...</ul>}
    </li>
  );
}

I separate concerns (e.g., presentation vs logic) and ensure keyboard navigation and accessibility.


5. What’s your approach to modeling HTML forms in a React application, especially for validation and submission?

I use controlled components for predictable state:

const [email, setEmail] = useState("");
<input value={email} onChange={(e) => setEmail(e.target.value)} />;

For validation:

<form onSubmit={handleSubmit(onSubmit)} />


6. How do you reason about the impact of HTML parsing and rendering on page load performance?

The critical rendering path is impacted by:

I optimize by:


7. What’s your mental model for handling HTML events in a React application versus vanilla JavaScript?

In React:

<button onClick={handleClick}>Click me</button>

Benefits:

In vanilla JS:

React simplifies the lifecycle and performance.


8. How do you design HTML structures to support progressive enhancement in a React-based application?

I build HTML to work without JavaScript first , then enhance with React.

Example:

Use:

<button type="submit">Search</button>

Enhancement adds filters, animations, etc. after hydration.


9. How do you think about the role of HTML in a server-side rendered (SSR) React application?

HTML is the initial render delivered to the browser in SSR:

My model:


I treat metadata as part of the dynamic route context . For SPAs:

<Helmet>
  <title>Product Page</title>
  <meta name="description" content="Details about product" />
</Helmet>

For PWAs, also manage <link rel="manifest">, icons, and preload hints.