Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

NodeJS Interview Questions and Answers

Related differences

Related differences

AngularJS vs NodeJSNodeJS vs JavaNodeJS vs Spring Boot
NodeJS vs Golang

Ques 11. Explain the purpose of the 'Buffer' class in Node.js.

The 'Buffer' class in Node.js is used to handle binary data. It provides a way to work with raw data directly without requiring encoding/decoding.

Example:

const buffer = Buffer.from('Hello, Node.js');

Is it helpful? Add Comment View Comments
 

Ques 12. What is the event loop in Node.js?

The event loop is a core concept in Node.js that allows the execution of non-blocking asynchronous operations. It continuously checks the message queue and executes callbacks when events occur.

Example:

console.log('Start');
setTimeout(() => console.log('Timeout'), 1000);
console.log('End');

Is it helpful? Add Comment View Comments
 

Ques 13. How does the 'require.resolve()' method work in Node.js?

'require.resolve()' is used to find the path of a module file. It returns the absolute path of the resolved module.

Example:

const path = require.resolve('path');

Is it helpful? Add Comment View Comments
 

Ques 14. Explain the purpose of the 'os' module in Node.js.

The 'os' module provides a way to interact with the operating system. It includes methods to get information about the operating system like CPU architecture, memory, and network interfaces.

Example:

const os = require('os');
console.log(os.totalmem());

Is it helpful? Add Comment View Comments
 

Ques 15. What is middleware in the context of Express.js?

Middleware functions in Express.js are functions that have access to the request, response, and next middleware function. They can modify the request and response objects, terminate the request-response cycle, or call the next middleware in the stack.

Example:

app.use((req, res, next) => { /* middleware logic */ next(); });

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2025 WithoutBook