Frontend Interview Questions I Was Asked

Today

Core Web Concepts

  1. What is the purpose of the <head> tag in HTML, and how do the async and defer attributes affect the loading and execution of external scripts?
  2. Explain the differences between var, let, and const in JavaScript. When would you use each?
  3. What is hoisting in JavaScript? How do call, apply, and bind work, and when would you use them?
  4. Can you explain the JavaScript event loop? How does it handle asynchronous operations?
  5. Solve and explain the output for tricky JavaScript questions involving closures, promises, and event loops.

React & State Management

  1. How does the useState hook work in React? How can you access the previous state when updating state?
  2. How are events processed in batches in React, and what are the benefits?
  3. What are React Hooks? Name a few and explain their use cases.
  4. How does the useEffect hook work, and how can you use its cleanup function to prevent memory leaks?
  5. Explain the React diffing algorithm, Fiber architecture, and how React detects changes in the DOM.

Performance & Optimization

  1. What are some common optimization techniques in React applications?
  2. Given a piece of code, how would you optimize its performance?
  3. How does React.memo help prevent unnecessary re-renders?
  4. How can passing children as props help avoid re-renders in React?
  5. How does composing components help avoid re-renders in React?
  6. Explain the use cases for useMemo, useCallback, useReducer, useDeferredValue, and useRef in React.

Modern JavaScript & Syntax

  1. How do you use export and import syntax in ES6 modules?
  2. What are the key differences between ES5 and ES6 syntax? What new features were introduced in ES6?

State Management Libraries

  1. What is Redux, and how does it help manage state in React applications?
  2. Why is immutability important in Redux, and how does Redux enforce it?
  3. How does the React Context API work, and when should you use it?

Advanced Patterns & APIs

  1. What are compound components in React, and how do they help in building flexible UIs?
  2. How do you create custom hooks in React, and what are some best practices?
  3. Compare cookies, localStorage, and IndexedDB for client-side storage. When would you use each?
  4. How do JavaScript promises work? What is an immediately resolved promise, and how do you use promise utility methods like all, any, and allSettled?
  5. In TypeScript, what are union and intersection types? Provide examples of when to use each.

Miscellaneous

  1. How can you synchronize tabs using browser events?
  2. How does the useReducer hook work in React, and when should you use it?