0% found this document useful (0 votes)
15 views6 pages

MERN Stack Interview Guide

The document is a comprehensive interview guide covering the MERN stack, which includes MongoDB, Express.js, React.js, and Node.js. It provides detailed explanations of key concepts, differences between technologies, and common interview questions and answers for each component of the stack. Additionally, it discusses integration techniques and best practices for full-stack development using the MERN architecture.

Uploaded by

sushank445
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views6 pages

MERN Stack Interview Guide

The document is a comprehensive interview guide covering the MERN stack, which includes MongoDB, Express.js, React.js, and Node.js. It provides detailed explanations of key concepts, differences between technologies, and common interview questions and answers for each component of the stack. Additionally, it discusses integration techniques and best practices for full-stack development using the MERN architecture.

Uploaded by

sushank445
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

MERN Stack Interview Guide (Beginner → Advanced)

A complete conceptual and interview-based guide to MongoDB, [Link], [Link], [Link],


and their integration for full-stack interviews.

1. MongoDB Interview Guide


MongoDB is a NoSQL, document-oriented database used to store unstructured data in JSON-
like format. It offers high scalability, flexibility, and performance.

1. 1. What is MongoDB?

MongoDB is a NoSQL database that stores data in flexible, JSON-like documents instead of
tables and rows.

2. 2. Difference between SQL and NoSQL?

SQL uses structured schema and tables, while NoSQL uses documents with dynamic
schemas.

3. 3. What is a collection?

A collection is a group of MongoDB documents similar to a table in relational databases.

4. 4. What is a document?

A record in MongoDB, stored as a JSON-like object with key-value pairs.

5. 5. How do you create a database in MongoDB?

You can use `use databaseName` to switch or create a database.

6. 6. What are indexes in MongoDB?

Indexes improve query performance by allowing faster data retrieval.

7. 7. What is an aggregation pipeline?

A framework for data analysis and transformation using stages like $match, $group, $sort.

8. 8. What is sharding?

A method to distribute data across multiple machines for horizontal scaling.

9. 9. What is replication?

It ensures data redundancy and high availability using replica sets.

10. 10. Explain the difference between find() and findOne().


find() returns multiple documents; findOne() returns a single document.

11. 11. What is ObjectId in MongoDB?

A unique 12-byte identifier automatically generated for each document.

12. 12. How can you improve MongoDB performance?

Use indexes, projection, and sharding; avoid large documents.

13. 13. What is $lookup used for?

To perform joins between two collections in an aggregation pipeline.

14. 14. What are capped collections?

Fixed-size collections that overwrite oldest documents when full.

15. 15. How to secure MongoDB?

Enable authentication, use role-based access, and bind IP addresses.

2. [Link] Interview Guide


[Link] is a minimal [Link] framework used for building RESTful APIs and web
applications efficiently.

16. 1. What is [Link]?

A [Link] web framework used to simplify server and routing management.

17. 2. Why use [Link]?

It simplifies handling HTTP requests, routing, and middleware integration.

18. 3. What is middleware?

Functions that execute before the route handler; used for logging, validation, etc.

19. 4. What is routing in Express?

Routing defines how an application responds to client requests for URLs.

20. 5. Difference between [Link]() and [Link]()?

[Link]() is for middleware; [Link]() is for handling GET routes.

21. 6. What is error-handling middleware?

Special middleware with four arguments (err, req, res, next) to catch errors.

22. 7. How do you handle 404 errors?


Use a middleware that sends 404 for unmatched routes.

23. 8. What are HTTP methods supported by Express?

GET, POST, PUT, DELETE, PATCH.

24. 9. How can you parse JSON data in Express?

Use built-in middleware: [Link]([Link]()).

25. 10. What is CORS?

Cross-Origin Resource Sharing — allows frontend from different origins to access APIs.

26. 11. How do you handle authentication in Express?

Use JWT tokens, sessions, or [Link] for user authentication.

27. 12. What is the difference between [Link]() and [Link]()?

[Link]() can send any type; [Link]() sends JSON response.

28. 13. How do you serve static files?

Use [Link]([Link]('public')).

29. 14. What are environment variables?

Configuration values stored securely using [Link].

30. 15. How to secure Express apps?

Use Helmet, sanitize input, and validate all requests.

3. [Link] Interview Guide


React is a frontend library for building user interfaces using components and a virtual DOM
for efficient rendering.

31. 1. What is React?

A JavaScript library for building dynamic user interfaces using reusable components.

32. 2. What is JSX?

A syntax extension that allows writing HTML inside JavaScript.

33. 3. What is the Virtual DOM?

An in-memory representation of the actual DOM that improves rendering speed.

34. 4. Difference between functional and class components?


Functional use hooks; class components use lifecycle methods.

35. 5. What are hooks in React?

Functions that let you use state and lifecycle features in functional components.

36. 6. Explain useState and useEffect.

useState manages component state; useEffect handles side effects.

37. 7. What are props?

Props are read-only inputs passed from parent to child components.

38. 8. What is state?

An object that stores data that influences component rendering.

39. 9. What is lifting state up?

Sharing state by moving it to the closest common ancestor component.

40. 10. What is React Router?

A library used for navigation in React applications.

41. 11. What is Redux?

A state management library for predictable application state flow.

42. 12. What are controlled components?

Components where form data is handled by React state.

43. 13. What is reconciliation?

Process by which React updates the DOM only where necessary.

44. 14. What are keys in lists?

Unique identifiers used by React to optimize list rendering.

45. 15. How do you optimize performance in React?

Use memoization, lazy loading, and avoid unnecessary re-renders.

4. [Link] Interview Guide


[Link] is a runtime environment that allows JavaScript to be executed on the server side
using the V8 engine.

46. 1. What is [Link]?


A JavaScript runtime built on Chrome’s V8 engine for server-side development.

47. 2. Why use [Link]?

For non-blocking, event-driven servers ideal for I/O-heavy applications.

48. 3. What is NPM?

Node Package Manager used to manage dependencies.

49. 4. What are modules?

Reusable code blocks; types: built-in, local, and third-party.

50. 5. What is the event loop?

Mechanism that handles asynchronous operations in [Link].

51. 6. What are streams?

Objects that enable reading/writing data in chunks.

52. 7. Difference between synchronous and asynchronous?

Synchronous blocks code; asynchronous executes non-blocking.

53. 8. What is callback hell?

Nested callbacks causing poor readability; solved by Promises/async-await.

54. 9. What is the purpose of [Link]?

Holds metadata and dependencies for a project.

55. 10. What is [Link]()?

Executes a callback after the current operation completes.

56. 11. How do you handle errors in Node?

Using try/catch blocks or error-first callbacks.

57. 12. What is cluster module?

Used to create multiple worker processes for load balancing.

58. 13. How to improve performance?

Use async programming, caching, and clustering.

59. 14. How to secure Node apps?


Validate inputs, sanitize data, use HTTPS, and Helmet.

60. 15. What is middleware in Node context?

Functions executed during request-response cycles.

5. MERN Integration and Full-Stack Q&A


61. 1. How do frontend and backend communicate?

Using REST APIs via HTTP requests (fetch or Axios).

62. 2. What is the MERN stack flow?

React (UI) → Express + Node (API) → MongoDB (Database).

63. 3. How do you connect MongoDB to [Link]?

Using Mongoose or the native MongoDB driver.

64. 4. What is Mongoose?

An ODM library for modeling MongoDB data in [Link].

65. 5. What is JWT authentication?

Token-based authentication method for secure user sessions.

66. 6. How do you deploy MERN apps?

Frontend to Vercel/Netlify, backend to Render/AWS, DB to Atlas.

67. 7. How do you handle environment variables?

Using dotenv package and [Link] variables.

68. 8. What is CORS and why needed?

Allows cross-origin API access between frontend and backend.

69. 9. How do you protect sensitive routes?

Use JWT verification middleware.

70. 10. What is the typical folder structure for MERN?

client/, server/, models/, routes/, controllers/, config/

You might also like