Let’s discuss some common questions that you should prepare for the interviews. These questions will be helpful in clearing the interviews specially for the backend development or full stack development role.
This set contains the basic questions asked in the interview.
1. What is Node.js?
3. Is Node.js single-threaded?
Yes, Node.js is a single-threaded application as it is built using the single-threaded event loop model architecture.
4. What kind of API function is supported by Node.js?
There are two types of API functions supported by Node.js:
- Synchronous: These API functions are used for non-blocking code.
- Asynchronous: These API functions are used for blocking code.
5. What is the difference between Synchronous and Asynchronous functions?
- Synchronous function: These are the function that block the execution of the program whenever an operation is performed. Hence these are also called blocking operations. We use these functions to perform lightweight tasks
- Asynchronous function: These are the operations that do not block the execution of the program and each command is executed after the previous command even if the previous command has not computed the result. We use these functions to perform heavy tasks.
6. What is a module in Node.js?
In Node.js Application, a Module can be considered as a block of code that provide a simple or complex functionality that can communicate with external application. Modules can be organized in a single file or a collection of multiple files/folders. Modules are useful because of their reusability and ability to reduce the complexity of code into smaller pieces. Some examples of modules are. http, fs, os, path, etc.
7. What is npm and its advantages?
NPM stands for Node Package Manager. It is an online repository for Node.js packages. We can install these packages in our projects/applications using the command line.
8. What is middleware?
Middleware is the function that works between the request and the response cycle. Middleware gets executed after the server receives the request and before the controller sends the response.
9. How does Node.js handle concurrency even after being single-threaded?
Node.js internally uses libuv library for handling all async call. This library creates multiple thread pools to handle async operations.
10. What is control flow in Node.js?
Control Flow functions are executed whenever there is an async call made in the program. These functions define the order in which these asynchronous functions will be executed.
11. What do you mean by event loop in Node.js?
Event Loop in Node.js is used to handle callbacks. It is helpful in performing non-blocking I/O operations. An event loop is an endless loop, which waits for tasks, executes them, and then sleeps until it receives more tasks.
12. What is the order in which control flow statements get executed?
The order in which the statements are executed is as follows:
- Execution and queue handling
- Collection of data and storing it
- Handling concurrency
- Executing the next lines of code
13. What are the main disadvantages of Node.js?
Since Node.js is single-threaded so multi-threaded engines are better and can handle tasks more efficiently. Also, we do not use relational databases with Node.js like MySQL mostly non-relational databases like MongoDB is used.
14. What is REPL in Node.js?
REPL in Node.js stands for Read, Evaluate, Print, and Loop. It is a computer environment similar to the shell which is useful for writing and debugging code as it executes the code in on go.
15. How to import a module in Node.js?
We use the require module to import the External libraries in Node.js. The result returned by require() is stored in a variable which is used to invoke the functions using the dot notation.
16. What is the difference between Node.js and AJAX?
17. What is package.json in Node.js?
package.json is a file that is used to store the metadata of all the contents of the project. It is used to describe the module used, run commands, and other useful information about the project.
18. How to write hello world using node.js?
Run this program from the command line and see the output in the browser window. This program prints Hello World on the browser when the browser sends a request through http://localhost:3000/.
19. What is the most popular Node.js framework used these days?
The most famous Node.js framework used is Express.js as it is highly scalable, efficient, and requires very few lines of code to create an application.
20. What are promises in Node.js?
Last Updated :
23 May, 2023