NodeJS Questions

Warm up for your NodeJS interview with most asked questions and answers for junior, mid, and senior roles.

Mid

What is the use of EventEmitter in Node.js?

Show Answer

EventEmitter is used to create events and emit events.

The EventEmitter is a module that facilitates communication/interaction between objects in Node. EventEmitter is at the core of Node asynchronous event-driven architecture.

Many of Node's built-in modules inherit from EventEmitter including prominent frameworks like Express.

Mid

Does Node.js supports cryptography?

Show Answer

The node:crypto module provides cryptographic functionality that includes a set of wrappers for OpenSSL's hash, HMAC, cipher, decipher, sign, and verify functions.

Mid

What are buffers in Node.js?

Show Answer
Buffers in Node.js is used to perform operations on raw binary data. Generally, Buffer refers to the particular memory location in memory.
Mid

What is the use of middleware in Node.js?

Show Answer

Middleware is a function that is called before the request is handled by the server. It is used to modify the request and response objects.

Mid

What are global objects in Node.js?

Show Answer

Global objects are objects that are available to all modules in Node.js.

Mid

Why is assert used in Node.js?

Show Answer

Assert is used to check if a condition is true or false.

Mid

What are stubs in Node.js?

Show Answer

Stubs are functions that are used to replace other functions in Node.js.

Mid

What are the timing features of Node.js?

Show Answer
  • setTimeout() Method: The setTimeout() method is used to schedule code execution after a designated amount of milliseconds.
  • setImmediate() Method: The setImmediate() method is used to execute code at the end of the current event loop cycle.
  • setInterval() Method: The setInterval() method is used to call a function at specified intervals (in milliseconds). It is used to execute the function only once after a specified period.
Mid

Are there any disadvantages to using Node.js?

Show Answer

Some of the disadvantages to using Node.js are:

  • Unstable API
  • Lack of Library support
  • High demand for experienced Resources
  • Heavy Computing Tasks
  • Asyncronous Programming Model
Mid

How can you avoid callbacks?

Show Answer

You can avoid callbacks by using promises.