1. Why is Node.js single-threaded?
Node.js works on the single-threaded model to ensure that there is support for asynchronous processing. With this, it makes it scalable and efficient for applications to provide high performance and efficiency under high amounts of load.
2. What are the different API functions supported by Node.js?
There are two types of API functions. They are as follows:
- Synchronous APIs: Used for non-blocking functions
- Asynchronous APIs: Used for blocking functions
3. What is the control flow function?
The control flow function is a common code snippet, which executes whenever there are any asynchronous function calls made, and they are used to evaluate the order in which these functions are executed in Node.js.
4. What are the asynchronous tasks that should occur in an event loop?
Following are some of the tasks that can be done using an event loop asynchronously:
- Blocking send requests
- High computational requirement
- Real-time I/O operations
5. What is the order of execution in control flow statements?
The following is the order in which control flow statements are used to process function calls:
- Handling execution and queue
- Data collection and storage
- Concurrency handling and limiting
- Execution of the next piece of code
6. What are the input arguments for an asynchronous queue?
There are two main arguments that an asynchronous queue uses. They are:
- Concurrency value
- Task function
7. What is the framework that is used majorly in Node.js today?
Node.js has multiple frameworks, namely:
Among these, the most used framework is Express.js for its ability to provide good scalability, flexibility, and minimalism.
8. What are the security implementations that are present in Node.js?
Following are the important implementations for security:
- Error handling protocols
- Authentication pipelines
9. What is the use of middleware in Node.js?
A middleware is a simple function that has the ability to handle incoming requests and outbound response objects. Middleware is used primarily for the following tasks:
- Execution of code (of any type)
- Updating request and response objects
- Completion of request–response iterations
- Calling the next middleware
10. What are stubs in Node.js?
Stubs are simply functions that are used to assess and analyze individual component behavior. When running test cases, stubs are useful in providing the details of the functions executed.
11. What is the use of REPL in Node.js?
12. What do you understand by the term I/O?
The term I/O stands for input and output. It is used to access anything outside of your application. The I/O describes any program, operation, or device that transfers data to or from a medium or another medium. This medium can be a physical device, network, or files within a system.
I/O is loaded into the machine memory to run the program once the application starts.
13. Why is Node.js Single-threaded?
Node.js is a single-threaded application with event looping for async processing. The biggest advantage of doing async processing on a single thread under typical web loads is that you can achieve more performance and scalability than the typical thread-based implementation.
14. What do you understand by the term fork in Node.js?
Generally, a fork is used to spawn child processes. In Node.js, it is used to create a new instance of the V8 engine to run multiple workers to execute the code.
15. What are buffers in Node.js?
16. What tools can be used to assure a consistent style in Node.js?
Following is a list of tools that can be used in developing code in teams, to enforce a given style guide and to catch common errors using static analysis.