Top 60+ Node.JS Interview Questions and answers

    1 Votes

47) How to concatenate buffers in NodeJS?

The syntax to concatenate buffers in NodeJS is
var MyConctBuffer = Buffer.concat([myBuffer1, myBuffer2]);
48) How to compare buffers in NodeJS?
To compare buffers in NodeJS, use following code –;


49) How to copy buffers in NodeJS?
Below is the syntax to copy buffers in NodeJS –
buffer.copy(targetBuffer[, targetStart][, sourceStart][, sourceEnd])
50) What are the differences between “readUIntBE” and “writeIntBE” in Node.JS?
  • readUIntBE - It’s a generalized version of all numeric read methods, which supports up to 48 bits accuracy. Setting noAssert to “true” to skip the validation.
  • writeIntBE - This will write the value to the buffer at the specified byteLength and offset and it supports upto 48 bits of accuracy.


51) Why to use “__filename” in Node.JS?

“__filename” is used to represent the filename of the code which is being executed. It used to resolve the absolute path of file. Below is the sample code for the same –


52) Why to use “SetTimeout” in Node.JS?

This is the global function and it is used to run the callback after some milliseconds.

Syntax of this method –

setTimeout(callbackmethod, millisecs)

53) Why to use “ClearTimeout” in Node.JS?

This is the global function and it is used to stop a timer which was created during “settimeout()”.

54) Explain Web Server?

It is a software app which will handle the HTTP requests by client (eg: browser) and will return web pages to client as a response. Most of web server supports – server side scripts using scripting languages. Example of web server is Apache, which is mostly used webserver.

55) List out the layers involved in Web App Architechure?

Below are the layers used in Web Apps –

  • Client - Which makes HTTP request to the server. Eg: Browsers.
  • Server – This layer is used to intercept the requests from client.
  • Business – It will have application server utilized by web servers for processing.
  • Data – This layer will have databases mainly or any source of data.

56) Explain “Event Emitter” in Node.JS?

It is a part of Events module. When instance of EventEmitter faces any error, it will emit an 'error' event. “Event Emitters” provides multiple properties like – “emit” and “on”.

  • “on” property is used for binding the function with event.
  • “emit” property is used for firing an event.

57) Explain “NewListener” in Node.JS?

This event is being emitted whenever any listener is added. So when event is triggered the listener may not have been removed from listener array for the event.

58) Why to use Net.socket in Node.JS?

This object is an abstraction of a local socket or TCP. net.Socket instances implement a duplex Stream interface. These can be created by the user and used as a client (with connect() function) or they can be created by Node and can be passed to the user through the 'connection' event of a server.

59) Which events are emitted by Net.socket?

Below are the list of events emitted by Net.socket –

  • Connect
  • Lookup
  • End
  • Data
  • Close
  • Drain
  • Timeout
  • Error

60) Explain “DNS module” in Node.JS?

This module is used for DNS lookup and to use underlying OS name resolution. This used to provide asynchronous network wrapper. DNS module can be imported like –

var mydns = require("dns")

61) Explain binding in domain module in Node.JS?

Below are the bindings in domain modules –

  • External Binding 
  • Internal Binding 

62) Explain RESTful Web Service?

Web services which uses REST architecture will be known as RESTful Web Services. These web services uses HTTP protocol and HTTP methods.

63) How to truncate the file in Node.JS?

Below command can be used for truncating the file –

fs.ftruncate(fd, len, callback)
Page 4 of 4

Popular Videos


How to improve your Interview, Salary Negotiation, Communication & Presentation Skills.

Got a tip or Question?
Let us know

Related Articles

HTML/HTML5 Interview Questions and Answers
JQuery Interview Questions and Answers
Javascript Interview Questions and Answers
Top AngularJS Questions and Answers
Top 70 CSS Interview Questions and Answers
React JS Interview Questions and Answers