Interview Q&A

Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.

4616 total questions 4516 technical 100 career & HR 4346 from PDF library

Showing 26–50 of 123

Career & HR topics

By tech stack

Mid PDF
What are worker threads in Node.js and when should you use them?

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. What interviewers…

Node.js Read answer
Mid PDF
How does garbage collection work in Node.js?

Node.js uses the V8 JavaScript engine’s garbage collector, which: Automatically frees memory that's no longer referenced. Uses a generational GC: young generation (short-lived objects) and old generation (long-lived obje…

Node.js Read answer
Junior PDF
What is load balancing and how does it apply to Node.js?

Load balancing distributes incoming requests across multiple server instances to: Improve performance Increase availability and fault tolerance In Node.js, you can: Use the cluster module to spawn workers on multiple CPU…

Node.js Read answer
Mid PDF
How do you connect Node.js with MySQL/PostgreSQL? You can use native drivers or ORMs like Sequelize. Example with MySQL native driver: const mysql = require('mysql2/promise');

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);…

Node.js Read answer
Junior PDF
What is Chai? Chai is an assertion library for Node.js that lets you write readable tests with different styles: Expect style (most popular): expect(result).to.equal(5); ● Should style: result.should.equal(5); ●

ssert style: ssert.equal(result, 5); What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (performance, maintainability, security, cost) When you would and would not use it in produc…

Node.js Read answer
Mid PDF
What are worker threads in 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.…

Node.js Read answer
Mid PDF
What are the key features of Node.js?

Asynchronous and Event-Driven: Handles multiple requests without blocking. Fast Execution: Powered by the V8 engine. Single-Threaded but Scalable: Uses event loop and callbacks for handling concurrency. Cross-platform: R…

Node.js Read answer
Mid PDF
Explain the difference between callbacks, promises, and async/await.

Callbacks: Functions passed as arguments, executed when async operation finishes. Can lead to “callback hell.” Promises: Objects representing future results; allow chaining with .then(). Async/await: Syntactic sugar over…

Node.js Read answer
Junior PDF
What is the difference between PUT and PATCH in REST APIs?

PUT: Replaces the entire resource with the data sent. If a field is missing in the request, it may get erased. Idempotent (same request repeated yields same result). PATCH: Applies partial updates to the resource. Only c…

Node.js Read answer
Mid PDF
How do you use Docker with Node.js?

Docker packages your app and its environment into a container for consistent deployment. Basic steps: Create a Dockerfile: FROM node:18 WORKDIR /app COPY package*.json ./ RUN npm install --production COPY . . CMD ["node"…

Node.js Read answer
Junior PDF
What is Sequelize?

Sequelize is a popular ORM for relational databases like MySQL, PostgreSQL, SQLite, and MSSQL. It allows you to: Define models with JavaScript classes Handle migrations and schema changes Write complex queries using Java…

Node.js Read answer
Mid PDF
How do you manage API keys securely?

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 ke…

Node.js Read answer
Junior PDF
What is Supertest and how is it used?

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'); // You…

Node.js Read answer
Mid PDF
What are child processes and how are they used?

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) =&g…

Node.js Read answer
Mid PDF
How is Node.js different from traditional web servers like Apache?

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 Websit…

Node.js Read answer
Mid PDF
How does Node.js handle memory management and what tools can you use to detect memory leaks?

V8 engine manages memory automatically with garbage collection. To detect leaks: Use tools like Chrome DevTools, node --inspect, or heapdump. Monitor memory usage over time. Look for increasing memory without release, wh…

Node.js Read answer
Junior PDF
What is backpressure in Streams?

Backpressure happens when data is produced faster than it can be consumed downstream. In Node.js streams, it's a built-in mechanism to: Pause the readable stream when the writable stream is overwhelmed. Prevent memory ov…

Node.js Read answer
Mid PDF
How do you handle logging in production?

Use logging libraries like winston or pino for structured logs. Separate logs into levels (info, warn, error). Output logs to files or external services (Logstash, Datadog, Splunk). Implement log rotation to prevent disk…

Node.js Read answer
Mid PDF
How do you handle database errors in Node.js?

Use try/catch blocks with async/await to catch exceptions. Handle errors in callbacks or promise .catch() when using promise-based APIs. Log errors for debugging. Return meaningful error messages to the client without ex…

Node.js Read answer
Mid PDF
How do you use environment variables in 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. What interviewers expect A c…

Node.js Read answer
Mid PDF
How do you mock dependencies in Node.js tests?

Mocking replaces real dependencies with fake versions to isolate the unit you’re testing. Common tools: Sinon: For mocks, spies, and stubs. Proxyquire: Replace dependencies when requiring modules. Jest: Has built-in mock…

Node.js Read answer
Junior PDF
What is the role of async/await in 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 some…

Node.js Read answer
Mid PDF
How do you create a custom Node.js module? You can make any .js file a reusable module by exporting functions, objects, or classes using module.exports. 📦 Step-by-step example: mathUtils.js — Custom module function add(a, b) { return a + b; } function subtract(a, b) { return a - b; } module.exports = { add, subtract };

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, a…

Node.js Read answer
Junior PDF
What is the event loop in Node.js? The event loop is the core of Node.js's non-blocking I/O operations. It handles all

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'); }, 20…

Node.js Read answer
Junior PDF
What is the difference between CommonJS and ES Modules (ESM) in Node.js? ● CommonJS (CJS): Uses require() and module.exports. Synchronous module loading. ● ES Modules: Uses import/export syntax. Supports asynchronous and static

nalysis. ESM is the modern standard but Node.js supports both. What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (performance, maintainability, security, cost) When you would and…

Node.js Read answer

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.

What interviewers expect

  • A clear definition tied to Node.js in Node.js projects
  • Trade-offs (performance, maintainability, security, cost)
  • When you would and would not use it in production

Real-world example

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.

How to explain in the interview

  1. Define the concept in one or two sentences.
  2. Context — where it fits in Node.js architecture.
  3. Example — a specific project, bug, or performance win.
  4. Trade-off — what you gain vs what you sacrifice.

Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.

Permalink & share

Node.js Node.js Tutorial · Node.js

Node.js uses the V8 JavaScript engine’s garbage collector, which:

  • Automatically frees memory that's no longer referenced.
  • Uses a generational GC: young generation (short-lived objects) and old generation

(long-lived objects).

  • Runs periodically to clean up unused objects.
  • Developers usually don’t control it directly, but can monitor memory and tune via flags
if needed.
Permalink & share

Node.js Node.js Tutorial · Node.js

Load balancing distributes incoming requests across multiple server instances to:

  • Improve performance
  • Increase availability and fault tolerance

In Node.js, you can:

  • Use the cluster module to spawn workers on multiple CPU cores.
  • Use external load balancers like Nginx, HAProxy, or cloud load balancers.
  • PM2 also supports clustering with:

pm2 start app.js -i max

Permalink & share

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); }

What interviewers expect

  • A clear definition tied to Node.js in Node.js projects
  • Trade-offs (performance, maintainability, security, cost)
  • When you would and would not use it in production

Real-world example

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.

How to explain in the interview

  1. Define the concept in one or two sentences.
  2. Context — where it fits in Node.js architecture.
  3. Example — a specific project, bug, or performance win.
  4. Trade-off — what you gain vs what you sacrifice.

Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.

Permalink & share

Node.js Node.js Tutorial · Node.js

ssert style: ssert.equal(result, 5);

What interviewers expect

  • A clear definition tied to Node.js in Node.js projects
  • Trade-offs (performance, maintainability, security, cost)
  • When you would and would not use it in production

Real-world example

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.

How to explain in the interview

  1. Define the concept in one or two sentences.
  2. Context — where it fits in Node.js architecture.
  3. Example — a specific project, bug, or performance win.
  4. Trade-off — what you gain vs what you sacrifice.

Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.

Permalink & share

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');

Permalink & share

Node.js Node.js Tutorial · Node.js

  • Asynchronous and Event-Driven: Handles multiple requests without blocking.
  • Fast Execution: Powered by the V8 engine.
  • Single-Threaded but Scalable: Uses event loop and callbacks for handling

concurrency.

  • Cross-platform: Runs on Windows, Linux, and macOS.
  • NPM (Node Package Manager): Massive ecosystem of reusable packages.
Permalink & share

Node.js Node.js Tutorial · Node.js

  • Callbacks: Functions passed as arguments, executed when async operation

finishes. Can lead to “callback hell.”

  • Promises: Objects representing future results; allow chaining with .then().
  • Async/await: Syntactic sugar over promises; lets you write async code that looks

synchronous, improving readability.

Permalink & share

Node.js Node.js Tutorial · Node.js

  • PUT: Replaces the entire resource with the data sent.
  • If a field is missing in the request, it may get erased.
  • Idempotent (same request repeated yields same result).
  • PATCH: Applies partial updates to the resource.
  • Only changes the fields specified.
  • Not necessarily idempotent.

Example: Updating user email.

  • PUT /users/1 with { "name": "Alice" } replaces whole user — email might

get removed.

  • PATCH /users/1 with { "email": "new@example.com" } updates just the

email.

Permalink & share

Node.js Node.js Tutorial · Node.js

Docker packages your app and its environment into a container for consistent deployment.

Basic steps:

  • Create a Dockerfile:

FROM node:18

WORKDIR /app

COPY package*.json ./

RUN npm install --production

COPY . .

CMD ["node", "app.js"]

  • Build and run the container:

docker build -t my-node-app .

docker run -p 3000:3000 my-node-app

Permalink & share

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:

  • Define models with JavaScript classes
  • Handle migrations and schema changes
  • Write complex queries using JavaScript instead of raw SQL
Permalink & share

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.

What interviewers expect

  • A clear definition tied to Node.js in Node.js projects
  • Trade-offs (performance, maintainability, security, cost)
  • When you would and would not use it in production

Real-world example

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.

How to explain in the interview

  1. Define the concept in one or two sentences.
  2. Context — where it fits in Node.js architecture.
  3. Example — a specific project, bug, or performance win.
  4. Trade-off — what you gain vs what you sacrifice.

Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.

Permalink & share

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();

});

});

});

Permalink & share

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.

Permalink & share

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.

Permalink & share

Node.js Node.js Tutorial · Node.js

V8 engine manages memory automatically with garbage collection.

To detect leaks:

  • Use tools like Chrome DevTools, node --inspect, or heapdump.
  • Monitor memory usage over time.
  • Look for increasing memory without release, which signals leaks.

Modules & Package Management

Permalink & share

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:

  • Pause the readable stream when the writable stream is overwhelmed.
  • Prevent memory overload and crashes.

This flow control allows producers and consumers to work in sync.

Permalink & share

Node.js Node.js Tutorial · Node.js

  • Use logging libraries like winston or pino for structured logs.
  • Separate logs into levels (info, warn, error).
  • Output logs to files or external services (Logstash, Datadog, Splunk).
  • Implement log rotation to prevent disk space issues.
  • Make logs easy to search and analyze.
Permalink & share

Node.js Node.js Tutorial · Node.js

  • Use try/catch blocks with async/await to catch exceptions.
  • Handle errors in callbacks or promise .catch() when using promise-based APIs.
  • Log errors for debugging.
  • Return meaningful error messages to the client without exposing sensitive info.

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');

}
Permalink & share

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.

What interviewers expect

  • A clear definition tied to Node.js in Node.js projects
  • Trade-offs (performance, maintainability, security, cost)
  • When you would and would not use it in production

Real-world example

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.

How to explain in the interview

  1. Define the concept in one or two sentences.
  2. Context — where it fits in Node.js architecture.
  3. Example — a specific project, bug, or performance win.
  4. Trade-off — what you gain vs what you sacrifice.

Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.

Permalink & share

Node.js Node.js Tutorial · Node.js

Mocking replaces real dependencies with fake versions to isolate the unit you’re testing.

Common tools:

  • Sinon: For mocks, spies, and stubs.
  • Proxyquire: Replace dependencies when requiring modules.
  • Jest: Has built-in mocking capabilities.

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();

});

});

Permalink & share

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);

}
}
Permalink & share

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

Permalink & share

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.

Permalink & share

Node.js Node.js Tutorial · Node.js

nalysis. ESM is the modern standard but Node.js supports both.

What interviewers expect

  • A clear definition tied to Node.js in Node.js projects
  • Trade-offs (performance, maintainability, security, cost)
  • When you would and would not use it in production

Real-world example

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.

How to explain in the interview

  1. Define the concept in one or two sentences.
  2. Context — where it fits in Node.js architecture.
  3. Example — a specific project, bug, or performance win.
  4. Trade-off — what you gain vs what you sacrifice.

Tip: Practice aloud on Toolliyo mock interview or the Interview Q&A section before your real interview.

Permalink & share
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details