NodeJs interview Questions

  nodeJs

we will discuss the topmost very important NodeJs interview Questions.this questions are commonly asked in every interview.

Can you explain What is Node.js?

Node.js is a server-side scripting language that is used to build scalable programs. Node.js is a server-side scripting language a web application framework built on Google Chrome’s JavaScript Engine.

Node.js is a server-side scripting language runs within the Node.js runtime on Mac OS, Windows, and Linux with no changes. This runtime facilitates you to execute a JavaScript code on any machine outside a browser.

What is the purpose of Node.js?

These are the following purposes of Node.js:

  1. Real-time web applications
  2. Distributed systems
  3. Network applications
  4. General-purpose applications

What is Package.json?

Package.json is present in the root directory of node application/modules and is used to define the properties of a package

 What is the difference between Node.js and Ajax?

Node.js and Ajax (Asynchronous JavaScript and XML) are the advanced implementation of JavaScript. They all serve completely different purposes.

Ajax is designed for dynamically updating a particular area data of a page’s content, without having to refresh the whole page.

Node.js is used for developing client-server applications.

Is Node a single-threaded application?

Yes. Node is a single-threaded application with event looping.

Is Node.js free to use?

Yes. It is released under MIT license and is free to use.

What are the advantages of Node.js?

  1. Node.js is asynchronous and event-driven. It moves to the next API after calling it, and a notification mechanism of Events of Node.js responds to the server from the previous API call.
  2. Node.js is very fast because it builds on Google Chrome?s V8 JavaScript engine. Its library is very fast in code execution.
  3. Node.js is single-threaded but highly scalable.
  4. Node.js provides a facility of no buffering. Its application never buffers any data. It outputs the data in chunks.

What are the streams in Node.js?

Node.js Streams are the objects types this stream facilitates to read data from a source and write data to a destination. There are four types of streams in Node.js:

Readable: it is used for reading operations.

Writable: it is used for write operations.

Duplex: it can be used for both reading and write operations.

Transform: Transform stream is a duplex stream where the output computes according to input data.

What is event-driven programming in Node.js?

In Node.js, event-driven programming means as soon as Node starts its server, it initiates its variables, declares functions, and then waits for an event to occur. this is the one of the reasons Node.js is pretty fast compared to other technologies.

What are the exit codes in Node.js? List some exit codes.

this type of code specific codes that are used to end a “process” like a global object used to represent a node process.

Examples of exit codes include:

* Unused
* Uncaught Fatal Exception
* Fatal Error
* Non-function Internal Exception Handler
* Internal Exception handler Run-Time Failure
* Internal JavaScript Evaluation Failure

What are globals in Node.js?

Three keywords in Node.js

Global – it represents the Global namespace object and acts as a container for all other objects.

Process – the process is a global objects but can turn asynchronous function into an async callback.
Buffer – it is a class in Node.js to handle binary data.