React , JavaScript and TypeScript Interview Questions
-
Microtasks vs MacroTasks
- What is the difference between Microtasks and Macrotasks in JavaScript’s event loop?
- Can you give an example of code that executes as a Microtask vs a Macrotask?
-
npm vs npx
- What is the difference between
npmandnpx? - When would you use
npxinstead ofnpm?
- What is the difference between
-
Class Components vs Function Components
- How do class components differ from function components in React?
- Which one is preferred in modern React and why?
-
DOM vs Virtual DOM
- What is the difference between the DOM and Virtual DOM in React?
- How does React’s Virtual DOM improve performance?
-
useMemo vs React.memo
- What’s the difference between
useMemoandReact.memo? - Give a use case where you would use
useMemoinstead ofReact.memo.
- What’s the difference between
-
Higher-Order Components (HOCs)
- What is a Higher-Order Component in React?
- Can you explain a real-world use case for HOCs?
-
Managing State in React
- What are the different ways to manage state in a React app?
- When would you choose Context API vs Redux for state management?
-
useLayoutEffect
- What is
useLayoutEffectand how is it different fromuseEffect? - When should you use
useLayoutEffect?
- What is
-
useRef vs createRef
- What’s the difference between
useRef(hook) andcreateRef(class-based)? - Can refs cause memory leaks?
- What’s the difference between
-
React Hook Form
- What is React Hook Form and why is it used?
- How does it compare with Formik?
-
Managing Data & Sending to API
- How do you manage form data in React and send it to an API?
- How would you handle API errors when submitting a form?
-
10 Text Boxes Form
- If you have 10 text inputs in a form, how would you manage their state?
- Would you use a single state object or multiple useState hooks? Why?
-
Redux
- What are the core principles of Redux?
- Can you explain the flow of data in Redux with an example?
-
Axios
- Why do we use Axios instead of Fetch API?
- How do you intercept requests and responses in Axios?
-
useFormContext Hook
- What is the purpose of
useFormContextin React Hook Form? - How does it help with deeply nested forms?
- What is the purpose of
-
Routing in React
- How does routing work in React using React Router?
- Difference between BrowserRouter and MemoryRouter?
-
Authentication & Authorization in React
- How do you implement authentication and authorization in React?
- How do you protect routes based on user roles?
-
Callback Queue & Callback Functions
- What is the callback queue in JavaScript’s event loop?
- How do callback functions work in asynchronous code?
-
Closures
- What is a closure in JavaScript?
- Can you give a practical example of a closure in React?
-
any vs unknown (TypeScript)
- What’s the difference between
anyandunknownin TypeScript? - Which one is safer and why?
- What’s the difference between
-
Tree Shaking in React
- What is tree shaking and how does it help in React apps?
- How can you ensure your code benefits from tree shaking?
-
JS Memory Management & Garbage Collection
- How does JavaScript manage memory?
- What are memory leaks and how can they be avoided?
-
Compound Component Pattern
- What is the compound component pattern in React?
- Can you give an example (like a Tab system)?
-
WeakMap vs WeakSet
- Difference between WeakMap and WeakSet?
- Why are they useful for memory management?
-
Shallow Copy vs Deep Copy
- Difference between shallow copy and deep copy?
- How would you create a deep copy in JavaScript?
-
Promises & Error Handling
- How do you handle errors in Promises?
- Difference between
.catchandtry...catchwith async/await?
-
Map, Filter, Reduce
- How do
map,filter, andreducediffer? - Write an example of each.
- How do
-
Debounce vs Throttle
- What is the difference between debouncing and throttling?
- Give a real-world scenario for each.
-
useTransition (React 18)
- What is
useTransitionin React? - How does it improve UI responsiveness?
- What is
-
Phases in Functional Components
- What are the different phases of a functional component lifecycle?
- How do hooks replace lifecycle methods?
-
Mounting & Unmounting
- What happens during mounting and unmounting in React?
- How can you perform cleanup on unmount?
-
Methods in Class Components
- What are lifecycle methods in class components?
- How do they compare with hooks in functional components?
-
BrowserRouter vs MemoryRouter
- Difference between BrowserRouter and MemoryRouter?
- When would you use MemoryRouter?
-
Hydration in React
- What is hydration in React?
- Why is it important for SSR (Server-Side Rendering)?
-
startTransition (React 18)
- What is
startTransitionand how is it different fromuseTransition? - Can you give an example?
- What is
-
Custom Hooks
- What are custom hooks in React?
- How do they improve reusability?
-
Synthetic Events in React
- What are synthetic events in React?
- How are they different from native DOM events?
-
Memory Leaks
- What causes memory leaks in React or JavaScript?
- How can you prevent them?
-
Lazy Loading & Performance Optimization
- How does lazy loading work in React?
- What other techniques can optimize React performance?
-
Calling Parent Function from Child
- Can a child component call a parent’s function in React?
- How would you implement it?
-
Memory Leak in React/JS
- What are common causes of memory leaks in React/JavaScript?
- How do you detect and fix them?
Comments
Post a Comment