+91 90691 39140 | +1 253 214 3115 | info@hub4tech.com | hub4tech

Top 35 Most Asked Node.js Interview Questions and Answers

Fri, 2017-11-03 18:52
Node.js Interview Questions

Are you preparing for Node.js job interview and wondering what questions you might be asked? In this blog we have hand-picked the questions you are likely to be asked in Node.js job interview and provided to-the-point answers to each one of them so as to help you prepare better for Node.js job interviews.

Always keep in the mind that, only academic knowledge is not enough to crack an interview. Employers expects from the candidate to have practical knowledge and hands-on experience as well. This Node.js Interview Questions designed by industry expert will help you to gain practical knowledge of Node.js.

Node.js Interview Questions and Answers

  1. What is node.js?

Node.js is a Server side scripting which is used to build scalable programs. Its multiple advantages over other server side languages, the prominent being non-blocking I/O.

  1. What do you mean by Asynchronous API?

All APIs of Node.js library are aynchronous that is non-blocking. It essentially means a Node.js based server never waits for a API to return data. Server moves to next API after calling it and a notification mechanism of Events of Node.js helps server to get response from the previous API call.

  1. How node.js works?

Node.js works on a v8 environment, it is a virtual machine that utilizes JavaScript as its scripting language and achieves high output via non-blocking I/O and single threaded event loop.

  1. Is it free to use Node.js?

Yes! Node.js is released under the MIT license and is free to use.

  1. What do you mean by the term I/O ?

I/O is the shorthand for input and output, and it will access anything outside of your application. It will be loaded into the machine memory to run the program, once the application is started.

  1. What does event-driven programming mean?

In computer programming, event driven programming is a programming paradigm in which the flow of the program is determined by events like messages from other programs or threads. It is an application architecture technique divided into two sections 1) Event Selection 2) Event Handling

  1. Can we evaluate simple expression using Node REPL


  1. Where can we use node.js?

Node.js can be used for the following purposes

  • Web applications ( especially real-time web apps )
  • Network applications
  • Distributed systems
  • General purpose applications
  1. What is the difference of using var and not using var in REPL while dealing with variables?

Use variables to store values and print later. if var keyword is not used then value is stored in the variable and printed. Wheras if var keyword is used then value is stored but not printed. You can use both variables later.

  1. What is the advantage of using node.js?

It provides an easy way to build scalable network programs

  • Generally fast
  • Great concurrency
  • Asynchronous everything
  • Almost never blocks
  1. What is Package.json?

package.json is present in the root directory of any Node application/module and is used to define the properties of a package.

  1. What are the two types of API functions in Node.js ?

The two types of API functions in Node.js are

  • Asynchronous, non-blocking functions
  • Synchronous, blocking functions
  1. What is a blocking code?

If application has to wait for some I/O operation in order to complete its execution any further then the code responsible for waiting is known as blocking code.

  1. What is control flow function?

A generic piece of code which runs in between several asynchronous function calls is known as control flow function.

  1. How Node prevents blocking code?

By providing callback function. Callback function gets called whenever corresponding event triggered.

  1. Why Node.js is single threaded?

For async processing, Node.js was created explicitly as an experiment. It is believed that more performance and scalability can be achieved by doing async processing on a single thread under typical web loads than the typical thread based implementation.

  1. What is Event Loop?

Node js is a single threaded application but it support concurrency via concept of event and callbacks. As every API of Node js are asynchronous and being a single thread, it uses async function calls to maintain the concurrency. Node uses observer pattern. Node thread keeps an event loop and whenever any task get completed, it fires the corresponding event which signals the event listener function to get executed.

  1. Using the event loop what are the tasks that should be done asynchronously?


  • I/O operations
  • Heavy computation
  • Anything requiring blocking
  1. What is purpose of Buffer class in Node?

Buffer class is a global class and can be accessed in application without importing buffer module. A Buffer is a kind of an array of integers and corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.

  1. Why node.js is quickly gaining attention from JAVA programmers?

Node.js is quickly gaining attention as it is a loop based server for JavaScript. Node.js gives user the ability to write the JavaScript on the server, which has access to things like HTTP stack, file I/O, TCP and databases.

  1. What is Piping in Node?

Piping is a mechanism to connect output of one stream to another stream. It is normally used to get data from one stream and to pass output of that stream to another stream. There is no limit on piping operations. Consider the above example, where we've read test.txt using readerStream and write test1.txt using writerStream. Now we'll use the piping to simplify our operation or reading from one file and writing to another file.

  1. What are the two arguments that async.queue takes?

The two arguments that async.queue takes

  • Task function
  • Concurrency value
  1. What is difference between synchronous and asynchronous method of fs module?

Every method in fs module have synchronous as well as asynchronous form. Asynchronous methods takes a last parameter as completion function callback and first parameter of the callback function is error. It is preferred to use asynchronous method instead of synchronous method as former never block the program execution where the latter one does.

  1. What is an event loop in Node.js ?

To process and handle external events and to convert them into callback invocations an event loop is used. So, at I/O calls, node.js can switch from one request to another .

  1. What are streams?

Streams are objects that let you read data from a source or write data to a destination in continous fashion.

  1. How Node.js overcomes the problem of blocking of I/O operations?

Node.js solves this problem by putting the event based model at its core, using an event loop instead of threads.

  1. How many types of streams are present in Node.

In Node.js, there are four types of streams.

  • Readable - Stream which is used for read operation.
  • Writable - Stream which is used for write operation.
  • Duplex - Stream which can be used for both read and write operation.
  • Transform - A type of duplex stream where the output is computed based on input.
  1. What is the difference between Node.js vs Ajax?

The difference between Node.js and Ajax is that, Ajax (short for Asynchronous Javascript and XML) is a client side technology, often used for updating the contents of the page without refreshing it. While,Node.js is Server Side Javascript, used for developing server software. Node.js does not execute in the browser but by the server.

  1. What is Chaining in Node?

Chanining is a mechanism to connect output of one stream to another stream and create a chain of multiple stream operations. It is normally used with piping operations.

  1. What are the Challenges with Node.js ?

Emphasizing on the technical side, it’s a bit of challenge in Node.js to have one process with one thread to scale up on multi core server.

  1. What is the purpose of __filename variable?

The __filename represents the filename of the code being executed. This is the resolved absolute path of this code file. For a main program this is not necessarily the same filename used in the command line. The value inside a module is the path to that module file.

  1. What does it mean “non-blocking” in node.js?

In node.js “non-blocking” means that its IO is non-blocking. Node uses “libuv” to handle its IO in a platform-agnostic way. On windows, it uses completion ports for unix it uses epoll or kqueue etc. So, it makes a non-blocking request and upon a request, it queues it within the event loop which call the JavaScript ‘callback’ on the main JavaScript thread.

  1. What is the purpose of __dirname variable?

The __dirname represents the name of the directory that the currently executing script resides in.

  1. What is the command that is used in node.js to import external libraries?

Command “require” is used for importing external libraries, for example, “var http=require (“http”)”. This will load the http library and the single exported object through the http variable.

  1. What is the purpose of clearTimeout function?

The clearTimeout( t ) global function is used to stop a timer that was previously created with setTimeout(). Here t is the timer returned by setTimeout() function.

Training with Hub4Tech:

To get training on any of the above certifications, you can choose Hub4Tech, which is one of the best online training platforms to get trained in the latest technology. Our industry experts train you through real-time problems and industry-based training. To get the complete information about security architect, please call us at +91 90691 39140

You can also write your queries at info@hub4tech.com. To get training in your favourite course from industry experts, please check our courses details here. Or if preparing yourself, you can also check your assessment level by participating in our online quiz, designed by technology experts based on industry standard.

If you liked the article and want to read other articles as well, read allHub4Tech Blogs here. Stay tuned to our FacebookTwitterand LinkedIn pages for latest updates, course info by Hub4Tech.

Hitesh Patel
Copyright ©2015 Hub4Tech.com, All Rights Reserved. Hub4Tech™ is registered trademark of Hub4tech Portal Services Pvt. Ltd.
All trademarks and logos appearing on this website are the property of their respective owners.