MEAN Questions Set 3
MEAN Questions Set 3
js) + JavaScript
Answer: `==` checks for equality after type coercion, while `===` checks for equality
without type coercion (strict equality).
Answer: A closure is a function that remembers its outer scope even after the outer
function has completed. It allows functions to access variables from an enclosing
scope or context.
Answer: `use strict` enables strict mode, which helps catch common coding errors
and prevents the use of certain unsafe features, like undeclared variables.
Answer: Error handling is done using `try`, `catch`, `finally`, and `throw` statements
to catch and handle exceptions gracefully.
Answer: Routing in Express.js maps HTTP requests (GET, POST, PUT, DELETE) to
specific URL paths and methods defined in the application, allowing you to handle
requests at different endpoints.
Answer: You can connect to MongoDB from a Node.js application using the
`mongoose` or `mongodb` package, specifying the connection URL with the database
name.
Answer: Mongoose is an ODM (Object Data Modeling) library for MongoDB and
Node.js, providing schema-based modeling and the ability to interact with MongoDB
using JavaScript objects.
12. What are CRUD operations in MongoDB, and how do you perform them?
Answer: CRUD stands for Create, Read, Update, Delete. They are performed using
MongoDB's methods like `insertOne`, `find`, `updateOne`, and `deleteOne`.
13. What is the Aggregation Framework in MongoDB?
Answer: Angular lifecycle hooks are special methods that get called at specific
stages of a component’s lifecycle, such as `ngOnInit`, `ngOnChanges`, and
`ngOnDestroy`.
Answer: HTTP requests are handled using the `HttpClient` module in Angular,
which allows you to make GET, POST, PUT, and DELETE requests to external APIs or
backends.
Answer: A RESTful API adheres to REST principles, where resources are accessed
and manipulated using HTTP methods (GET, POST, PUT, DELETE) and stateless
communication.
23. What are streams in Node.js, and how are they used?
Answer: Streams in Node.js are used to handle data efficiently in chunks instead of
loading the entire data into memory. They are useful for reading or writing large
files.
Answer: Authentication can be implemented using JWT (JSON Web Tokens) where
the backend (Node.js) generates a token after verifying user credentials, and the
frontend (Angular) stores and sends the token with every request.
25. What is the difference between session-based and token-based authentication?
Answer: `next()` is a callback function in Express.js that passes control to the next
middleware or route handler in the stack.
28. What are the benefits of using TypeScript in a MEAN stack application?
Answer: TypeScript offers static typing, better code organization, and improved
tooling support, which makes it easier to write and maintain large-scale MEAN stack
applications.
Answer: Best practices include using proper HTTP methods (GET, POST, PUT,
DELETE), meaningful status codes, versioning the API, using pagination for large
datasets, and ensuring secure communication (HTTPS).
31. What is CORS, and how do you handle it in Node.js?
34. What is JWT, and how does it work in a MEAN stack application?
Answer: JWT (JSON Web Token) is used for secure authentication. After the user is
authenticated, a token is generated and sent to the client. The client includes the
token in subsequent requests for authorization.
36. What are NoSQL databases, and why is MongoDB considered one?
39. What are single-page applications (SPAs), and how does Angular support them?
Answer: SPAs