5 Commonly Asked NodeJS Interview Questions

When should and shouldn’t you use Node.js?

  • Realtime applications like chat and live update providing applications.
  • Streaming applications that stream video or other multimedia content to a large audience.
  • Other I/O intensive applications like collaborative platforms.
  • Web backends that follow microservices architecture.

What does EventEmitter do?

const events = require("events");
const eventEmitter = new events.EventEmitter();
const eventListener = function(){
console.log("event triggered");
eventEmitter.on("emitted", eventListener);eventEmitter.emit("emitted");

What is Node’s event loop?

What are Node Streams?

  • Readable
  • Writable
  • Duplex (both readable and writable)
  • Transform (A type of duplex stream. Its output is calculated using the input)
const fs = require("fs");
const readableStream = fs.createReadStream("test.txt");
let content = "";
readableStream.on("data", (chunk) => {
content += chunk;
readableStream.on("end", () => {

What is the difference between readFile and createReadStream functions?

const fs = require("fs");fs.readFile("test.txt", (err, content) => {
console.log( content);



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store