• +91 9723535972
  • info@interviewmaterial.com

NodeJS Interview Questions and Answers

NodeJS Interview Questions and Answers

Question - 31 : - What are streams in Node.js?

Answer - 31 : - 34. What are streams in Node.js? Streams are a set of data entities in Node.js. These can be considered similar to the working of strings and array objects. Streams are used for continuous read/write operations across a channel. But, if the channel is not available, then all of the data cannot be pushed to the memory at once. Hence, using streams will make it easy to process a large set of data in a continuous manner. Next up on this compilation of top node js interview questions for experienced, let us check out the advanced category of questions.

Question - 32 : - What are the types of streams available in Node.js?

Answer - 32 : - Node.js supports a variety of streams, namely: • Duplex (both read and write) • Readable streams • Writable streams • Transform (duplex for modifying data)

Question - 33 : - What is the use of REPL in Node.js?

Answer - 33 : - REPL stands for Read-Eval-Print-Loop. It provides users with a virtual environment to test JavaScript code in Node.js. To launch REPL, a simple command called ‘node’ is used. After this, JavaScript commands can be typed directly into the command line.

Question - 34 : - What is meant by tracing in Node.js?

Answer - 34 : - Tracing is a methodology used to collect all of the tracing information that gets generated by V8, the node core, and the userspace code. All of these are dumped into a log file and are very useful to validate and check the integrity of the information being passed.

Question - 35 : - Where is package.json used in Node.js?

Answer - 35 : - The ‘package.json’ file is a file that contains the metadata about all items in a project. It can also be used as a project identifier and deployed as a means to handle all of the project dependencies.

Question - 36 : - What is the difference between readFile and createReadStream in Node.js?

Answer - 36 : - • readFile: This is used to read all of the contents of a given file in an asynchronous manner. All of the content will be read into the memory before users can access it. • create ReadStream: This is used to break up the field into smaller chunks and then read it. The default chunk size is 64 KB, and this can be changed as per requirement

Question - 37 : - What is the use of the crypto module in Node.js?

Answer - 37 : - The crypto module in Node.js is used to provide users with cryptographic functionalities. This provides them with a large number of wrappers to perform various operations such as cipher, decipher, signing, and hashing operations

Question - 38 : - What is a passport in Node.js?

Answer - 38 : - Passport is a widely used middleware present in Node.js. It is primarily used for authentication, and it can easily fit into any Express.js-based web application. With every application created, it will require unique authentication mechanisms. This is provided as single modules by using passport, and it becomes easy to assign strategies to applications based on requirements, thereby avoiding any sort of dependencies.

Question - 39 : - How to get information about a file in Node.js?

Answer - 39 : - The fs.stat function is used to get the required information from a file. The syntax is as follows: fs.stat(path, callback) where, • Path is the string that has the path to the name • Callback: The callback function where stats is an object of fs.stats Next up on these Node js interview questions, you need to understand about DNS lookup.

Question - 40 : - What is the difference between setImmediate() and setTimeout()?

Answer - 40 : - The setImmediate() function is meant to execute a single script once the current event loop is complete. The setTimeout() function is used to hold a script and schedule it to be run after a certain time threshold is over. The order of execution will solely depend on the context in which the functions are called. If called from the main module, the timing will be based on the performance of the process.


NCERT Solutions

 

Share your email for latest updates

Name:
Email:

Our partners