Technical interview Q&A plus 100+ career & HR questions—notice period, salary negotiation, resume, LinkedIn, freelancing, AI careers, and behavioral interviews with detailed, real-world answers.
40 MCQs per stack · 80% pass · certificate + per-question feedback
40 questions · 60 min · Pass 80%
Start practice exam40 questions · 60 min · Pass 80%
Start practice exam40 questions · 60 min · Pass 80%
Start practice examNode.js Node.js Tutorial · Node.js
Node.js is an open-source, cross-platform runtime environment that allows you to run
JavaScript on the server side. It’s built on the V8 JavaScript engine developed by Google
(the same one used in Chrome). With Node.js, you can build scalable and high-performance
web applications, APIs, and even real-time services like chat apps.
📌 Example:
If you write a simple HTTP server in Node.js, you can serve a webpage without using a
traditional web server like Apache:
const http = require('http');
http.createServer((req, res) => {
res.end('Hello from Node.js server!');
}).listen(3000);
Node.js Node.js Tutorial · Node.js
current operation completes, before the event loop continues.
Example:
process.nextTick(() => console.log('nextTick'));
setImmediate(() => console.log('setImmediate'));
console.log('sync');
Output:
sync
nextTick
setImmediate
nextTick runs before any I/O or timers; setImmediate runs after I/O callbacks.
Node.js Node.js Tutorial · Node.js
If an error (exception) is thrown but not caught, Node.js will:
Why? Because an uncaught exception might leave the app in an inconsistent state.
Best practice: Use try/catch for synchronous code, and listen to
'uncaughtException' or 'unhandledRejection' events to log errors and gracefully
shut down:
process.on('uncaughtException', (err) => {
console.error('Uncaught Exception:', err);
process.exit(1); // Exit to avoid unstable state
});
Node.js Node.js Tutorial · Node.js
sync function connect() {
const uri = 'mongodb://localhost:27017/mydatabase';
const client = new MongoClient(uri);
try {
wait client.connect();
console.log('Connected to MongoDB');
const db = client.db('mydatabase');
// Use `db` to query collections
} catch (err) {
console.error(err);
} finally {
wait client.close();
}
}
connect();
Node.js Node.js Tutorial · Node.js
Node.js Node.js Tutorial · Node.js
s expected.
Basic example using Mocha and Chai:
// calculator.js
function add(a, b) {
return a + b;
}
module.exports = add;
// test/calculator.test.js
const add = require('../calculator');
const { expect } = require('chai');
describe('add function', () => {
it('should return the sum of two numbers', () => {
const result = add(2, 3);
expect(result).to.equal(5);
});
});
Run tests with:
mocha
This test suite checks if add(2,3) equals 5 — simple and effective.
Node.js Node.js Tutorial · Node.js
time per process. Clustering allows you to create multiple Node.js processes (workers)
that share the same server port. This way, your app can utilize multiple CPU cores and
handle more requests concurrently.
📌 Example: Using the built-in cluster module, you can fork multiple workers.
Node.js Node.js Tutorial · Node.js
Node.js operates on a single-threaded, event-driven architecture. It uses the event loop
to handle multiple connections concurrently, which means it can perform non-blocking I/O
operations efficiently.
📌 Real-life analogy:
Think of it like a chef (Node.js) who takes multiple orders (requests) but doesn't cook each
dish one at a time. Instead, they prep and send off tasks (e.g., grilling, baking) and move on
to the next customer while waiting.
Node.js Node.js Tutorial · Node.js
EventEmitter allows objects to emit named events and listen for them.
Example:
const EventEmitter = require('events');
const emitter = new EventEmitter();
emitter.on('greet', (name) => {
console.log(`Hello, ${name}!`);
});
emitter.emit('greet', 'Alice');
Output: Hello, Alice!
It’s fundamental for asynchronous communication in Node.js.
Node.js Node.js Tutorial · Node.js
Node.js uses a single-threaded event loop to handle concurrency. This design:
thread pool.
So, Node.js can handle many tasks concurrently without spawning multiple OS threads for
each.
Node.js Node.js Tutorial · Node.js
Process management means keeping your app running reliably, restarting it if it crashes, and
managing multiple instances.
PM2 is a popular Node.js process manager that:
Run your app with PM2 like this:
pm2 start app.js
pm2 monit
Node.js Node.js Tutorial · Node.js
Mongoose is an ODM (Object Data Modeling) library for MongoDB in Node.js. It provides:
You define schemas and models to interact with MongoDB more intuitively.
Node.js Node.js Tutorial · Node.js
concatenation.
Example with MySQL:
connection.query('SELECT * FROM users WHERE id = ?', [userId],
callback);
Node.js Node.js Tutorial · Node.js
Answer: Mocha: Flexible test runner, widely used. Jest: Full-featured, zero-config, includes mocks and coverage. Jasmine: Behavior-driven development framework. AVA: Minimalistic and fast. Tape: Simple and small footprint.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Node.js Node.js Tutorial · Node.js
Node.js is awesome for I/O-heavy, real-time apps, but it’s not ideal for:
requests.
Node.js is not designed for parallel CPU-heavy workloads by default.
machine learning) have better ecosystems in other languages.
Node.js Node.js Tutorial · Node.js
HashiCorp Vault.
Node.js Node.js Tutorial · Node.js
ge: Number,
createdAt: { type: Date, default: Date.now }
});
const User = mongoose.model('User', userSchema);
// Usage example
sync function createUser() {
const user = new User({ name: 'Alice', email: 'alice@example.com',
ge: 25 });
wait user.save();
console.log('User saved');
}Node.js Node.js Tutorial · Node.js
require('dotenv').config(); console.log(process.env.DB_PASSWORD);
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Avoid directly inserting user input into queries. Use safe query methods (e.g., Mongoose’s query APIs). Validate and sanitize input. For example, don’t allow user input to modify query operators like $gt, $ne.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: nd allows async testing. It does not provide assertions, so it’s often paired with assertion libraries like Chai.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
PM2 is a popular production process manager for Node.js applications. It helps you:
npm install pm2 -g
pm2 start app.js -i max # Runs in cluster mode with max CPU cores
Node.js Node.js Tutorial · Node.js
📌 Middleware example:
function auth(req, res, next) {
const token = req.headers.authorization?.split(' ')[1];
if (!token) return res.status(401).send('Unauthorized');
try {
const user = jwt.verify(token, 'secret');
req.user = user;
next();
} catch {
res.status(403).send('Invalid token');
}
}Node.js Node.js Tutorial · Node.js
The V8 engine is a high-performance JavaScript engine developed by Google for Chrome.
Node.js uses it to compile and run JavaScript code on the server side. It converts JS code
into machine code, making it fast and efficient.
📌 Use Case:
When you run a .js file with Node.js, the V8 engine compiles your code into machine code
behind the scenes.
Node.js Node.js Tutorial · Node.js
phases.
Node.js uses the event loop to handle async tasks without blocking.
Main phases:
Tasks are processed in this order each loop iteration.
Node.js Node.js Tutorial · Node.js
Node.js uses the V8 JavaScript engine’s garbage collector, which:
(long-lived objects).
if needed.Node.js Node.js Tutorial · Node.js
Load balancing distributes incoming requests across multiple server instances to:
In Node.js, you can:
pm2 start app.js -i max
Node.js Node.js Tutorial · Node.js
Answer: sync function connect() { const connection = await mysql.createConnection({ host: 'localhost', user: 'root', database: 'test' }); const [rows] = await connection.execute('SELECT * FROM users'); console.log(rows); }
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
ssert style: ssert.equal(result, 5);
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Worker threads allow you to run JavaScript code in parallel on multiple threads within the
same process — useful for CPU-intensive tasks like image processing or complex
calculations without blocking the main event loop.
const { Worker } = require('worker_threads');
const worker = new Worker('./worker.js');
worker.on('message', (msg) => console.log('From worker:', msg));
worker.postMessage('start');
Node.js Node.js Tutorial · Node.js
concurrency.
Node.js Node.js Tutorial · Node.js
Answer: Worker threads run JavaScript code in parallel threads — useful for CPU-intensive tasks that block the event loop. Use them when your app needs heavy computation without blocking other requests.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
finishes. Can lead to “callback hell.”
synchronous, improving readability.
Node.js Node.js Tutorial · Node.js
Answer: Never hardcode keys in your source code. Store them in environment variables or secure vaults. Use .env files with .gitignore to avoid committing secrets. Rotate keys regularly. Use scopes/permissions to limit key usage.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Supertest is a library for testing HTTP APIs, especially Express apps.
It allows you to simulate HTTP requests and assert on responses.
Example:
const request = require('supertest');
const app = require('../app'); // Your Express app
describe('GET /users', () => {
it('should return 200 and a list of users', (done) => {
request(app)
.get('/users')
.expect(200)
.expect('Content-Type', /json/)
.end((err, res) => {
if (err) return done(err);
done();
});
});
});
Node.js Node.js Tutorial · Node.js
Example: Updating user email.
get removed.
email.
Node.js Node.js Tutorial · Node.js
Docker packages your app and its environment into a container for consistent deployment.
Basic steps:
FROM node:18
WORKDIR /app
COPY package*.json ./
RUN npm install --production
COPY . .
CMD ["node", "app.js"]
docker build -t my-node-app .
docker run -p 3000:3000 my-node-app
Node.js Node.js Tutorial · Node.js
Sequelize is a popular ORM for relational databases like MySQL, PostgreSQL, SQLite, and
MSSQL.
It allows you to:
Node.js Node.js Tutorial · Node.js
Child processes are separate processes spawned by your Node.js app to run shell
commands or other programs, enabling parallel execution.
const { exec } = require('child_process');
exec('ls -la', (err, stdout, stderr) => {
if (err) console.error(err);
console.log(stdout);
});
Useful for running system commands or scripts without blocking your main app.
Node.js Node.js Tutorial · Node.js
Feature Node.js Apache
Thread Model Single-threaded event loop Multi-threaded
I/O Non-blocking Blocking by default
Performance Very high for I/O operations Good but resource
intensive
Use Case Real-time apps, APIs Websites, PHP apps
📌 Example:
For a chat application or API server with thousands of concurrent users, Node.js performs
better than Apache.
Node.js Node.js Tutorial · Node.js
Answer: You can access environment variables using process.env. const port = process.env.PORT || 3000; These variables are set outside your app, often in your shell or deployment environment.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Mocking replaces real dependencies with fake versions to isolate the unit you’re testing.
Common tools:
Example with Sinon:
const sinon = require('sinon');
const myModule = require('../myModule');
const dependency = require('../dependency');
describe('test with mock', () => {
it('should call dependency once', () => {
const stub = sinon.stub(dependency, 'someMethod').returns(42);
const result = myModule.doSomething();
sinon.assert.calledOnce(stub);
stub.restore();
});
});
Node.js Node.js Tutorial · Node.js
synchronous operations in a single thread, constantly checking for events (e.g., incoming
data, timers) and executing associated callbacks.
📌 Example:
setTimeout(() => {
console.log('Executed after 2 seconds');
}, 2000);
This callback is scheduled by the event loop and executed when the time is up.
Node.js Node.js Tutorial · Node.js
Node.js Node.js Tutorial · Node.js
Example:
try {
const user = await User.findById(id);
if (!user) throw new Error('User not found');
} catch (error) {
console.error(error);
res.status(500).send('Something went wrong');
}Node.js Node.js Tutorial · Node.js
V8 engine manages memory automatically with garbage collection.
To detect leaks:
Modules & Package Management
Node.js Node.js Tutorial · Node.js
sync/await provides a cleaner syntax for handling asynchronous code, making it look
synchronous and easier to read compared to nested callbacks or promise chains.
sync function fetchData() {
try {
const data = await someAsyncFunction();
console.log(data);
} catch (err) {
console.error(err);
}
}Node.js Node.js Tutorial · Node.js
Backpressure happens when data is produced faster than it can be consumed downstream.
In Node.js streams, it's a built-in mechanism to:
This flow control allows producers and consumers to work in sync.
Node.js Node.js Tutorial · Node.js
pp.js — Use the custom module
const math = require('./mathUtils');
console.log(math.add(5, 3)); // Output: 8
console.log(math.subtract(10, 4)); // Output: 6
✅ This pattern helps you break code into organized, testable, and reusable pieces — just
like using built-in or third-party libraries.
dvanced Node.js Concepts
Node.js Node.js Tutorial · Node.js
Answer: sync function getUser() { try { const user = await getUserFromDB(); return user; } catch (error) { console.error('Error fetching user:', error); } } Without try/catch, unhandled promise rejections can crash your app.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: dotenv is a library to load environment variables from a .env file into process.env.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Test coverage shows how much of your code is tested (lines, branches, functions).
Tools to measure:
Run coverage with nyc:
nyc mocha
It outputs stats like:
Security in Node.js
Node.js Node.js Tutorial · Node.js
sync queues (e.g., with libraries like async.queue) allow you to:
Example with async library:
const async = require('async');
const queue = async.queue(async (task) => {
wait doWork(task);
}, 2); // concurrency = 2
queue.push({ id: 1 });
queue.push({ id: 2 });
Node.js internally uses libuv’s thread pool for async I/O, but the event loop manages task
scheduling on the single main thread.
dditional Important Node.js Questions
& Answers
Core Concepts & Runtime
Node.js Node.js Tutorial · Node.js
like Prometheus + Grafana.
Node.js Node.js Tutorial · Node.js
nalysis. ESM is the modern standard but Node.js supports both.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
wait User.create([{ name: 'Bob' }], { session });
wait Order.create([{ userId: user._id }], { session });
wait session.commitTransaction();
} catch (error) {
wait session.abortTransaction();
} finally {
session.endSession();
}
const t = await sequelize.transaction();
try {
wait User.create({ name: 'Bob' }, { transaction: t });
wait Order.create({ userId: user.id }, { transaction: t });
wait t.commit();
} catch (error) {
wait t.rollback();
}
Deployment & Production
Node.js Node.js Tutorial · Node.js
database) to complete before moving to the next one. Node.js uses callbacks, promises, or
sync/await to handle the results when they're ready.
📌 Example:
const fs = require('fs');
fs.readFile('file.txt', 'utf8', (err, data) => {
if (err) throw err;
console.log(data);
});
console.log('Reading file...');
You’ll see "Reading file..." first, even though the file is being read.
Node.js Node.js Tutorial · Node.js
Answer: nodemon is a development tool that automatically restarts your Node.js app when file changes are detected—great for faster development cycles. It’s not recommended for production. Usage: nodemon app.js
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Global objects are available in all modules without the need to import them. Examples
include:
Node.js Node.js Tutorial · Node.js
Node.js searches in this order:
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Sanitize user inputs and outputs. Use libraries like DOMPurify for front-end. Use HTTP headers like Content Security Policy (CSP) via Helmet. Escape data before rendering in HTML.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
I/O) to complete.
// Synchronous (blocks event loop)
const data = fs.readFileSync('file.txt');
// Asynchronous (non-blocking)
fs.readFile('file.txt', (err, data) => {
if (err) throw err;
console.log(data);
});
Node.js Node.js Tutorial · Node.js
CI/CD stands for Continuous Integration and Continuous Deployment.
GitHub Actions, Jenkins).
Benefits:
Typical pipeline steps:
Node.js Node.js Tutorial · Node.js
process is a global object that provides information and control over the current Node.js
process.
📌 Examples:
console.log(process.pid); // Process ID
console.log(process.platform); // OS platform
You can also handle exit events:
process.on('exit', () => {
console.log('Exiting...');
});
Node.js Node.js Tutorial · Node.js
Answer: It specifies the entry point file of a package (default is index.js). When someone imports your package, Node.js loads the file in main.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: sync function read() { const content = await readFile('file.txt', 'utf8'); console.log(content); }
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
📌 Example:
console.log(__dirname); // /Users/yourname/project
console.log(__filename); // /Users/yourname/project/app.js
These are very useful for reading or writing files relative to the script's location.
PM and Module Management
Node.js Node.js Tutorial · Node.js
const bcrypt = require('bcrypt');
const hash = await bcrypt.hash(password, 10);
const match = await bcrypt.compare(inputPassword, storedHash);
Database Integration
Node.js Node.js Tutorial · Node.js
Both create child processes, but:
const { spawn, exec } = require('child_process');
// spawn example
const ls = spawn('ls', ['-lh', '/usr']);
ls.stdout.on('data', (data) => console.log(`Output: ${data}`));
// exec example
exec('ls -lh /usr', (error, stdout) => console.log(stdout));Node.js Node.js Tutorial · Node.js
NPM stands for Node Package Manager. It is the default package manager for Node.js and
is used to install, share, and manage reusable packages or libraries.
It comes pre-installed with Node.js and gives you access to a huge ecosystem of
open-source tools.
📌 Example Use:
npm install express
This command downloads the Express.js library into your project.
✅ NPM also:
Node.js Node.js Tutorial · Node.js
Answer: Avoid blocking the event loop. Use asynchronous APIs. Use clustering or worker threads. Cache results where possible. Profile and fix bottlenecks. Use load balancers for scaling horizontally.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: EventEmitter is a core class that allows objects to emit named events and register listeners to respond.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Blocking happens when synchronous code takes too long, preventing other events from processing. Detect with tools like: clinic.js — Event Loop Delay tool. Manual timing (setInterval to check delay).
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Local Installation (default):
Installs the package into the node_modules folder of your current project.
npm install lodash
Global Installation:
Installs the package system-wide, making it available in the command line anywhere.
npm install -g nodemon
Node.js Node.js Tutorial · Node.js
Answer: const EventEmitter = require('events'); const emitter = new EventEmitter(); emitter.on('greet', (name) => { console.log(`Hello, ${name}!`); }); emitter.emit('greet', 'Alice'); // Output: Hello, Alice!
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Clustering runs multiple Node.js instances on different CPU cores sharing the same server port. This spreads load and uses full CPU capacity, increasing concurrency.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
📌 Example: express, mongoose
📌 Example: nodemon, eslint, jest
📦 These are defined in package.json:
"dependencies": {
"express": "^4.18.0"
},
"devDependencies": {
"nodemon": "^3.0.0"
}
✅ Install a dev dependency with:
npm install nodemon --save-dev
Node.js Node.js Tutorial · Node.js
Answer: pp.use((req, res, next) => { console.log('Middleware 1'); next(); }); pp.use((req, res, next) => { console.log('Middleware 2'); res.send('Done'); });
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: llowing it to handle thousands of concurrent connections efficiently without creating threads per connection.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Semantic Versioning (semver) is a versioning system that uses the format:
MAJOR.MINOR.PATCH
Example: 2.5.3
📌 Example:
If a package moves from 1.2.0 to 2.0.0, it likely has breaking changes.
In package.json, you might see:
"express": "^4.17.1"
Node.js Node.js Tutorial · Node.js
Answer: Deploy multiple instances on different machines or containers. Use a load balancer to distribute traffic. Share state externally (e.g., Redis) since instances are stateless.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: The cluster module lets you fork your Node.js process to create worker processes that share the same server port, improving CPU utilization. Testing Node.js Applications
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
To update all packages to their latest safe versions based on semver:
npm update
To update a specific package to its latest version:
npm install express@latest
For a more interactive way:
npx npm-check-updates -u
npm install
✅ The npm-check-updates tool helps update versions in your package.json.
Node.js Node.js Tutorial · Node.js
Answer: Global variables holding references. Event listeners not removed. Closures holding onto variables. Caches growing without limits. Security & Best Practices
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Use rate limiting. Validate and sanitize inputs. Avoid blocking event loop. Use security middleware like helmet. Use a reverse proxy with DDoS protection.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pp.js const math = require('./mathUtils'); console.log(math.add(5, 3)); // 8 console.log(math.subtract(9, 4)); // 5 ✅ This is how you break your code into reusable pieces (modules) in Node.js. REST API Development in Node.js
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
pplications. It uses standard HTTP methods to perform CRUD operations on resources,
which are typically represented as URLs.
✅ A RESTful API allows different systems (like frontend apps or mobile apps) to interact
with your server over HTTP in a stateless manner.
📌 Example:
Node.js Node.js Tutorial · Node.js
Answer: Ensuring incoming data matches expected format to avoid injection attacks, crashes, or invalid data storage.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Strip out dangerous characters. Use libraries like validator.js. Escape output in HTML contexts.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: RESTful APIs use the following standard HTTP methods: Method Purpose GET Retrieve data POST Create new data PUT Update existing PATCH Partial update DELETE Remove data
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
pp.use(cors({ origin: ' }));
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
HTTP status codes indicate the result of a request:
Code Meaning
200 OK
201 Created
400 Bad Request
401 Unauthorized
403 Forbidden
404 Not Found
500 Internal Server Error
📌 Example:
res.status(201).json({ message: 'User created successfully' });
Node.js Node.js Tutorial · Node.js
Answer: pp.use(express.json()); pp.get('/api/users', (req, res) => { res.json([{ id: 1, name: 'Alice' }]); }); pp.listen(3000, () => console.log('Server running'));
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Validate file types and sizes. Store files outside of the web root. Use libraries like multer. Scan files for malware. REST API & Web Development
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Use query parameters like ?page=2&limit=10 to return chunks of data instead of all at once.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pplications and APIs by handling routing, middleware, requests, responses, and more. ✅ It’s like jQuery for the backend — removes the boilerplate.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: n operation is idempotent if repeating it has the same effect as doing it once (e.g., PUT). Important for safe retries.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pp.get('/users', (req, res) => { res.send('Get all users'); }); pp.post('/users', (req, res) => { res.send('Create user'); });
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Use middleware like express-rate-limit to limit the number of requests per IP.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pp.get('/users/:id', (req, res) => { const id = req.params.id; res.send(`User ID: ${id}`); }); Request to /users/42 returns: User ID: 42
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Websockets enable two-way real-time communication over a single TCP connection. Use libraries like socket.io.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pp.use(express.json()); This enables the app to read req.body in JSON POST/PUT requests.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Stateless: Each request is independent; no session stored on server. Stateful: Server keeps session info (like login status). Stateless apps scale easier. Testing & Debugging
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: PIs. ✅ Use the cors middleware: npm install cors const cors = require('cors'); pp.use(cors()); You can also customize it: pp.use(cors({ origin: ' }));
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pp.use((req, res, next) => { console.log(`${req.method} ${req.url}`); next(); // Move to next middleware or route });
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Use console.log for quick checks. Use node --inspect and Chrome DevTools. Use debuggers in IDEs (VSCode). Use profiling tools like clinic.js.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pp.use () Middleware for all requests pp.get () Handle only GET requests 📌 Example: pp.use(authMiddleware); // Runs on all routes pp.get('/data', handler); // Runs only for GET /data
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Write tests before code, then develop just enough to pass tests. Use frameworks like Mocha or Jest.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Use libraries like nock to intercept and mock HTTP calls.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pp.use((req, res) => { res.status(404).json({ message: 'Route not found' }); });
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Use tools like Apache JMeter, k6, or Artillery to simulate many users and measure performance. Ecosystem & Tools
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: pp.post('/users', body('email').isEmail(), (req, res) => { const errors = validationResult(req); if (!errors.isEmpty()) return res.status(400).json({ errors: errors.array() }); res.send('User created'); });
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Node Version Manager lets you install and switch between Node.js versions easily.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
ll support schema-based and custom validations.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Uses semantic versioning: MAJOR.MINOR.PATCH. New major versions can include breaking changes.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: uthorization: Bearer <token> The server verifies the token on every request.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: npm: Default Node package manager. yarn: Faster installs, better caching. pnpm: Efficient disk usage by linking packages.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Babel: Transpiles modern JS to compatible versions. TypeScript: Adds static typing and compiles to JS.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
JWT (JSON Web Token) is a compact, URL-safe token used for securely transmitting
information.
📌 Generate:
const jwt = require('jsonwebtoken');
const token = jwt.sign({ id: user.id }, 'secret', { expiresIn: '1h'
});
📌 Verify:
jwt.verify(token, 'secret');
Node.js Node.js Tutorial · Node.js
Answer: pp.post('/upload', upload.single('file'), (req, res) => { res.send('File uploaded'); });
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
Answer: Use testing frameworks: Jest or Mocha for unit tests Supertest for HTTP API testing 📌 Example with Supertest: const request = require('supertest'); request(app) .get('/api/users') .expect(200) .then(res => { console.log(res.body); });
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
pp.use(morgan('dev')); Logs every request with method, status, time, etc.
In a production Node.js application, teams apply this when handling user-facing features or integration boundaries. For example, you might use it during a sprint where reliability and observability matter—logging metrics, validating edge cases, and documenting the decision in an ADR so future developers understand why the approach was chosen.
Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.
Node.js Node.js Tutorial · Node.js
NPM and module-related Node.js
interview questions