[ad_1]
NodeJS is an open-source and cross-platform runtime atmosphere constructed on Chrome’s V8 JavaScript engine for executing JavaScript code exterior of a browser. It’s good to recollect that NodeJS isn’t a framework, and it’s not a programing language. It offers an event-driven, non-blocking (asynchronous) I/O and cross-platform runtime atmosphere for constructing extremely scalable server-side purposes utilizing JavaScript.

NodeJS Interview Questions & Solutions
We now have already created Fundamental Degree NodeJS Interview Questions and Solutions – Set 1
This set incorporates the intermediate-level questions requested within the interview.
1. What’s event-driven programming in Node.js?
Occasion-driven programming is used to synchronize the incidence of a number of occasions and to make this system so simple as potential. The essential parts of an Occasion-Pushed Program are:
- A callback perform ( referred to as an occasion handler) is known as when an occasion is triggered.
- An occasion loop that listens for occasion triggers and calls the corresponding occasion handler for that occasion.
2. What’s buffer in Node.js?
The Buffer class in Node.js is used to carry out operations on uncooked binary information. Typically, Buffer refers back to the explicit reminiscence location in reminiscence. Buffer and array have some similarities, however the distinction is array may be any kind, and it may be resizable. Buffers solely take care of binary information, and it can’t be resizable. Every integer in a buffer represents a byte. console.log() perform is used to print the Buffer occasion.
3. What are streams in Node.js?
Streams are a kind of data-handling technique and are used to learn or write enter into output sequentially. Streams are used to deal with studying/writing information or exchanging info in an environment friendly method. The stream module offers an API for implementing the stream interface. Examples of the stream object in Node.js is usually a request to an HTTP server and course of.stdout are each stream situations.
4. Clarify crypto module in Node.js
The crypto module is used for encrypting, decrypting, or hashing any kind of information. This encryption and decryption principally assist to safe and add a layer of authentication to the information. The principle use case of the crypto module is to transform the plain readable textual content to an encrypted format and decrypt it when required.
5. What’s callback hell?
Callback hell is a matter induced as a result of a nested callback. This causes the code to appear to be a pyramid and makes it unable to learn To beat this example we use guarantees.
6. Clarify the usage of timers module in Node.js?
The Timers module in Node.js incorporates varied features that permit us to execute a block of code or a perform after a set time frame. The Timers module is world, we don’t want to make use of require() to import it.
It has the next strategies:
7. Distinction between setImmediate() and course of.nextTick()
The method.nextTick() technique is used so as to add a brand new callback perform at the beginning of the following occasion queue. it’s referred to as earlier than the occasion is processed. The setImmediate is known as on the verify section of the following occasion queue. It’s created within the ballot section and is invoked in the course of the verify section.
8. What’s the distinction between setTimeout() and setImmediate() technique?
The setImmediate perform is used to execute a specific script instantly whereas the setTimeout perform is used to carry a perform and execute it after a specified time frame.
9. What’s the distinction between spawn() and fork() technique?
Each these strategies are used to create new little one processes the one distinction between them is that spawn() technique creates a brand new perform that Node runs from the command line whereas fork() perform creates an occasion of the prevailing fork() technique and creates a number of employees to carry out on the identical job.
10. Clarify the usage of passport module in Node.js
The passport module is used for including authentication options to our web site or internet app. It implements authentication measure which helps to carry out sign-in operations.
11. What’s fork in Node.js?
Fork is a technique in Node.js that’s used to create little one processes. It helps to deal with the rising workload. It creates a brand new occasion of the engine which allows a number of processes to run the code.
12. What are the three strategies to keep away from callback hell?
The three strategies to keep away from callback hell are:
- Utilizing async/await()
- Utilizing guarantees
- Utilizing turbines
13. What’s body-parser in Node.js?
Physique-parser is the Node.js body-parsing middleware. It’s liable for parsing the incoming request our bodies in a middleware earlier than you deal with it. It’s an NPM module that processes information despatched in HTTP requests.
14. What’s CORS in Node.js?
The phrase CORS stands for “Cross-Origin Useful resource Sharing”. Cross-Origin Useful resource Sharing is an HTTP-header primarily based mechanism applied by the browser which permits a server or an API to point any origins (completely different by way of protocol, hostname, or port) apart from its origin from which the unknown origin will get permission to entry and cargo sources. The cors package deal out there within the npm registry is used to sort out CORS errors in a Node.js utility.
15. Clarify the tls module in Node.js?
The tls module offers an implementation of the Transport Layer Safety (TLS) and Safe Socket Layer (SSL) protocols which might be constructed on prime of OpenSSL. It helps to ascertain a safe connection on the community.
16. What’s the usage of url module in Node.js?
In Node.js url module is used to separate the URL of the web site into components in order that it turns into readable and can be utilized within the completely different components of the appliance. The parse() technique is used with the url module to separate the URL of the web site into components.
17. What’s REST API?
Representational State Switch (REST) is an architectural fashion that defines a set of constraints for use for creating internet companies. REST API is a method of accessing internet companies in a easy and versatile method with out having any processing. It really works after the request is distributed from the shopper to the server within the type of an online URL as HTTP GET or POST or PUT or DELETE request. After that, a response comes again from the server within the type of a useful resource which may be something like HTML, XML, Picture, or JSON. However now JSON is the most well-liked format being utilized in Internet Companies.
18. Clarify the engine Google makes use of for Node.js?
The engine utilized by Google for Node.js is V8. It’s one the quickest engine as it’s written in C++. It offers a runtime atmosphere for the execution of JavaScript code. One of the best half is that the JavaScript engine is totally impartial of the browser through which it runs. It has an enormous neighborhood and is extremely moveable.
19. Title the instrument used for writing constant code?
ESLint is a instrument utilized in many IDEs to put in writing constant code types. ESLint is written utilizing Node.js to offer a quick runtime atmosphere and simple set up through npm.
20. What are the completely different sorts of HTTP requests?
Probably the most generally used HTTP requests are:
- GET: This request is used to learn/retrieve information from an online server. GET returns an HTTP standing code of 200 (OK) if the information is efficiently retrieved from the server.
- PUT: This request is used to switch the information on the server. It replaces your entire content material at a specific location with information that’s handed within the physique payload. If there are not any sources that match the request, it is going to generate one.
- POST: This request is used to ship information (file, type information, and many others.) to the server. On profitable creation, it returns an HTTP standing code of 201.
- DELETE: This request is used to delete the information on the server at a specified location.
Final Up to date :
07 Jun, 2023
Like Article
Save Article
[ad_2]