0% found this document useful (0 votes)
36 views2 pages

Node.js Question Bank for Developers

The document is a Node.js question bank containing various questions categorized into 2, 3, and 4 marks. It covers fundamental concepts such as Node.js, NPM, Event Loop, middleware in Express.js, and advanced topics like RESTful API creation, file uploads, and database connections. The questions are designed to assess knowledge on Node.js architecture, asynchronous operations, and best practices for application security.

Uploaded by

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

Node.js Question Bank for Developers

The document is a Node.js question bank containing various questions categorized into 2, 3, and 4 marks. It covers fundamental concepts such as Node.js, NPM, Event Loop, middleware in Express.js, and advanced topics like RESTful API creation, file uploads, and database connections. The questions are designed to assess knowledge on Node.js architecture, asynchronous operations, and best practices for application security.

Uploaded by

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

Node.

js Question Bank

2 Marks Questions

1. What is [Link]?

2. What is NPM?

3. What is the role of the Event Loop in [Link]?

4. Define REPL in [Link].

5. What is the purpose of [Link]?

6. What are buffers in [Link]?

7. What is the use of __dirname and __filename in [Link]?

8. What is the difference between [Link]() and setImmediate()?

9. What is a callback function in [Link]?

10. What is middleware in [Link]?

3 Marks Questions

1. Explain the difference between exports and [Link] in [Link].

2. How does [Link] handle asynchronous operations?

3. What is the purpose of the Cluster module in [Link]?

4. Describe the use of streams in [Link].

5. What is the difference between synchronous and asynchronous functions in [Link]?

6. How do you handle exceptions in [Link]?

7. What is the significance of the EventEmitter class in [Link]?

8. Explain the concept of middleware in [Link].

9. What are the differences between readFile and createReadStream in [Link]?

10. How does [Link] handle child processes?

4 Marks Questions

1. Explain the architecture of [Link] and how it handles concurrent requests.

2. Describe the steps to create a RESTful API using [Link].

3. How does the Event Loop work in [Link]?

4. What are the different types of streams in [Link], and how are they used?
5. Explain the process of handling file uploads in [Link].

6. How can you manage environment variables in a [Link] application?

7. Describe the process of connecting a [Link] application to a MongoDB database.

8. What are the best practices for securing a [Link] application?

9. How do you implement authentication in a [Link] application?

10. What are the common performance bottlenecks in [Link] applications, and how can they
be addressed?

11. What is the role of HTTP module in [Link]?

12. How do you create a simple server using [Link]?

13. What is CORS and how is it handled in [Link]?

14. Explain how to perform routing in [Link].

15. What is the purpose of using body-parser middleware in [Link]?

16. Write a program which uses add Listener (). method of Event Emitter class.

17. Write a code for selecting all records from Player's table

18. Write a program to use SQL SELECT Qvery to show data from a table using node. JS and
MYSQLdata base.

19. Write a program which uses addlistener ( ) method of Event Emmitter class.

20. Write a Program to define Module Circle. JS which exports the functions area ( ) and
Circumference ( ) and display the details on console.

Common questions

Powered by AI

The EventEmitter class in Node.js provides a core pattern for handling asynchronous events. Node.js, being event-driven, commonly uses this class to emit and handle events, where functions (listeners) are executed in response to events emitted. This enables decoupling message or event producers from consumers, promoting asynchronous behavior and facilitating complex event-driven architectures .

Synchronous functions in Node.js block the thread, waiting for operations to complete, while asynchronous functions allow other code to run, markedly enhancing responsiveness. Synchronous designs are straightforward but can lead to inefficient CPU utilization under I/O-bound scenarios. Asynchronous functions utilize callbacks, promises, or async/await patterns to optimize resource usage and maintain the application’s responsiveness even under concurrent requests, essential for non-blocking and scalable designs .

Middleware functions are used in Express.js to process requests and responses, allowing for functionalities such as logging, authentication, or handling errors. Middleware functions can modify request and response objects, execute code, end request-response cycle, or call the next middleware function in the stack. Examples include body-parser for parsing request bodies, and morgan for logging. Middleware enables modularization and reusability of code .

Node.js handles file uploads by parsing incoming files in multipart/form-data format using middleware like multer. The major steps include configuring multer to specify storage options, file size limits, and destination paths, followed by accessing uploaded files within the request object for further processing, such as saving to disk or database, while managing server-side validations and potential errors during the upload process .

Streams in Node.js provide an efficient mechanism for reading or writing data, handling it in chunks rather than loading everything into memory at once. There are various types of streams including readable, writable, duplex, and transform streams, each suited for different I/O operations. Streams enable processing of data as it arrives, allowing for faster and resource-efficient applications that utilize backpressure to handle flow appropriately. This contrasts with traditional I/O operations that can lead to high memory usage and inefficiencies .

process.nextTick() executes callbacks at the end of the current operation, before the event loop continues, while setImmediate() queues the callback for the next iteration of the event loop. This means process.nextTick() is used to execute code after the current operation ends, but before the I/O event handling starts. Choosing between them affects when in the event cycle your code will run, impacting performance and timing .

The Cluster module in Node.js allows for the creation of child processes that share the same server port, enabling Node.js to take advantage of multi-core systems and distribute requests efficiently across multiple processes. This improves the application performance by providing increased throughput and reliability, as each process can handle separate incoming connections, and the load is balanced automatically .

Best practices for securing Node.js applications include validating and sanitizing user input to avoid injection attacks, using HTTPS to encrypt communications, regularly updating dependencies to patch vulnerabilities, employing security tools like Helmet to set HTTP headers, and using environment variables for sensitive data management. These practices mitigate risks such as SQL injections, XSS, CSRF, and unauthorized data access .

REPL in Node.js (Read-Eval-Print Loop) is an interactive shell that processes Node.js JavaScript expressions, facilitating debugging and experimentation in real-time. package.json serves a different purpose; it's a manifest file in a Node.js project that contains metadata and is crucial for defining dependencies, scripts, and project information. While REPL is a developer tool for real-time evaluation, package.json manages the application environment and dependencies .

Node.js employs a non-blocking, event-driven architecture using the Event Loop to handle multiple connections concurrently on a single thread. This model, facilitated by callbacks and asynchronous processing, efficiently manages I/O operations without CPU waiting time. However, due to its single-threaded nature, it's limited in handling CPU-intensive tasks simultaneously, which may hinder performance under computationally heavy operations without adequate load-balancing, potentially addressed by the Cluster module .

You might also like