NodeJs interview questions
Master NodeJs interview questions with 24+ curated problems, answer outlines, and placement-focused preparation.
- 24+ topic questions
- Covers interview-ready concepts and answers
- Free practice for placement preparation
Preview Questions
-
Why is Node.js single-threaded, and how does it handle concurrency?
Node.js is single-threaded because it is built on the JavaScript runtime, which was originally designed to run inside web browsers for handling user interactions efficiently without the complexity of multithreading....
-
If you perform a CPU-intensive task in Node.js, what happens to other incoming requests?
Node.js runs on a single main thread that handles all incoming client requests through its event loop. This works great for I/O-bound tasks (like reading files or querying databases), because Node can delegate those...
-
Explain the difference between CommonJS and ES Modules in Node.js.
In Node.js, there are two main ways to write modular code — CommonJS (CJS) and ES Modules (ESM). Both are used for importing and exporting code between files, but they work differently in syntax and behavior. CommonJS...
-
Can you explain the internal mechanism behind require() in Node.js?
In Node.js, the require() function is used to import modules so you can reuse code written in other files. But behind the scenes, it does much more than just loading a file. When you call require('moduleName'), Node.js...
-
What is the Event Loop in Node.js?
The Event Loop is the core of Node.js's non-blocking I/O model. It's a mechanism that continuously checks for events or callbacks that need to be executed. The Event Loop works in phases: timers, pending callbacks,...
-
What is npm and package.json?
npm stands for Node Package Manager. It's the default package manager for Node.js and allows developers to install, manage, and share reusable code packages. The package.json file is a metadata file that contains...
-
What is Callback Hell (Pyramid of Doom)?
Callback Hell is a situation where callbacks are nested deeply within each other, making the code hard to read and maintain. This happens when you have multiple asynchronous operations that depend on each other. For...
-
Explain Middleware in Node.js.
Middleware is a function that has access to the request object (req), response object (res), and the next middleware function in the request-response cycle. Middleware functions can execute code, modify request/response...