✅ Web development Interview Questions with Answers Part-5
41. Why do we use frontend frameworks like React or Angular?
Answer: They help manage complex UI state. They enforce structure and reusability. They reduce manual DOM manipulation. This improves maintainability in large applications.
42. What is the Virtual DOM and how does it improve performance?
Answer: The Virtual DOM is a lightweight copy of the real DOM. Changes happen in memory first. Only the minimum required updates reach the real DOM. This reduces expensive DOM operations.
43. What are controlled and uncontrolled components?
Answer: Controlled components store input state in JavaScript. Uncontrolled components rely on the DOM for state. I prefer controlled components for validation and consistency. Uncontrolled components work for simple forms.
44. What is the difference between state and props?
Answer: Props pass data from parent to child. State manages local component data. Props are read-only. State changes trigger re-renders.
45. What are component lifecycle methods or hooks?
Answer: They let components react to creation, updates, and cleanup. In React, hooks replace lifecycle methods. useEffect handles side effects. Cleanup prevents memory leaks.
46. How does the dependency array in useEffect work?
Answer: It controls when the effect runs. Empty array runs once on mount. Values inside trigger re-runs on change. Wrong dependencies cause bugs or infinite loops.
47. When should you use Context API?
Answer: When data is needed across many components. Examples include theme, auth state, language. I avoid it for frequently changing data due to re-renders.
48. How do you optimize frontend application performance?
Answer: I avoid unnecessary re-renders. I memoize heavy components. I lazy-load routes. I reduce bundle size and API calls.
49. What is code splitting and why is it needed?
Answer: Code splitting loads only required code. It reduces initial bundle size. It improves first load performance. Commonly used with lazy loading.
50. What is the difference between server-side rendering and client-side rendering?
Answer: CSR renders content in the browser. SSR renders content on the server. SSR improves SEO and first paint. CSR works well for dashboards.
Double Tap ♥️ For Part-6
Post #3428
3.96K
- ❤ 14
- 👍 2