Home / Interview / Node.js :: General Questions

Interview :: Node.js

1) 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.

2) Is Node.js free to use?

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

3) Is Node a single threaded application?

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

4) 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
5) 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.

Node.js web layer


7) 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
8) What is error-first callback?

Error-first callbacks are used to pass errors and data. If something goes wrong, the programmer has to check the first argument because it is always an error argument. Additional arguments are used to pass data.

9) What is an asynchronous API?

All the API's of Node.js library are asynchronous means non-blocking. A Node.js based server never waits for an API to return data. The Node.js server moves to the next API after calling it, and a notification mechanism of Events of Node.js responds to the server for the previous API call.

10) How can you avoid callbacks?

To avoid callbacks, you can use any one of the following options:

  • You can use modularization. It breaks callbacks into independent functions.
  • You can use promises.
  • You can use yield with Generators and Promises.