Node.js Interview Questions – Set 01

Is Node.js free to use?

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

Is Node a single threaded application?

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

What is the purpose of Node.js?

These are the following purposes of Node.js:

  • Real-time web applications
  • Network applications
  • Distributed systems
  • General purpose applications

What are the advantages of Node.js?

Following are the main advantages of Node.js:

  • Node.js is asynchronous and event-driven. All API?s of Node.js library are non-blocking, and its server doesn’t wait for an API to return data. 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.
  • Node.js is very fast because it builds on Google Chrome?s V8 JavaScript engine. Its library is very fast in code execution.
  • Node.js is single threaded but highly scalable.
  • Node.js provides a facility of no buffering. Its application never buffers any data. It outputs the data in chunks.

Explain Node.js web application architecture?

A web application distinguishes into 4 layers:

  • Client Layer: The Client layer contains web browsers, mobile browsers or applications which can make an HTTP request to the web server.
  • Server Layer: The Server layer contains the Web server which can intercept the request made by clients and pass them the response.
  • Business Layer: The business layer contains application server which is utilized by the web server to do required processing. This layer interacts with the data layer via database or some external programs.
  • Data Layer: The Data layer contains databases or any source of data.

What do you understand by the term I/O?

I/O stands for input and output. It accesses anything outside of your application. It loaded into the machine memory to run the program, once the application starts.

What is Node.js?

Node.js is Server-side scripting which is used to build scalable programs. It is a web application framework built on Google Chrome’s JavaScript Engine. It 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 use of the underscore variable in REPL?

In REPL, the underscore variable is used to get the last result.

How many types of API functions are available in Node.js?

There are two types of API functions in Node.js:

  • Asynchronous, Non-blocking functions
  • Synchronous, Blocking functions

What is the use of a buffer class in Node.js?

The Node.js provides Buffer class to store raw data similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. It is a global class and can be accessed in an application without importing a buffer module. Buffer class is used because pure JavaScript is not compatible with binary data. So, when dealing with TCP streams or the file system, it’s necessary to handle octet streams.