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 74

Career & HR topics

By tech stack

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
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
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
Mid PDF
How does the async queue work in Node.js? Node.js uses the event loop with phases (timers, I/O callbacks, idle, poll, check, close callbacks) to manage async tasks.

sync queues (e.g., with libraries like async.queue) allow you to: Control concurrency (limit how many async tasks run simultaneously). Queue tasks and process them in order. Example with async library: const async = requ…

Node.js Read answer
Mid PDF
How do you monitor performance in a Node.js app?

Use monitoring tools like New Relic, Datadog, AppDynamics, or open-source tools like Prometheus + Grafana. Track metrics: response time, CPU/memory usage, error rates. Use Node.js built-in profilers or clinic.js to analy…

Node.js Read answer
Mid PDF
What are transactions and how are they handled? Transactions allow multiple database operations to execute atomically — either all succeed or none do — ensuring data consistency. ● In MongoDB (using Mongoose): const session = await mongoose.startSession(); session.startTransaction(); try {

wait User.create([{ name: 'Bob' }], { session }); wait Order.create([{ userId: user._id }], { session }); wait session.commitTransaction(); } catch (error) { wait session.abortTransaction(); } finally { session.endSessio…

Node.js Read answer
Mid PDF
How does error handling work in async/await? You handle errors using try/catch blocks around await statements.

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…

Node.js Read answer
Mid PDF
Explain the non-blocking I/O model in Node.js. Non-blocking I/O means the application doesn't wait for a task (like reading a file or querying

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

Node.js Read answer
Mid PDF
How does Node.js resolve modules when you call require()?

Node.js searches in this order: 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…

Node.js Read answer
Mid PDF
How do you prevent Cross-Site Scripting (XSS)?

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

Node.js Read answer
Mid PDF
What are global objects in Node.js?

Global objects are available in all modules without the need to import them. Examples include: __dirname: Directory name of the current module __filename: Full path of the current module global: Similar to window in brow…

Node.js Read answer
Mid PDF
How do you secure user passwords?

Always hash passwords before storing (never store plaintext). Use strong, slow hashing algorithms like bcrypt, argon2, or scrypt. Add a salt to each password (bcrypt does this automatically). Use libraries like bcrypt: c…

Node.js Read answer
Mid PDF
How do you optimize Node.js applications for high throughput?

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

Node.js Read answer
Mid PDF
How do you emit and listen for events?

Answer: const EventEmitter = require('events'); const emitter = new EventEmitter(); emitter.on('greet', (name) => { console.log(`Hello, ${name}!`); }); emitter.emit('greet', 'Alice'); // Output: Hello, Alice! What…

Node.js Read answer
Mid PDF
How do you install a package globally vs locally?

Local Installation (default): Installs the package into the node_modules folder of your current project. npm install lodash ✅ Used when the package is needed as part of your app's code. Global Installation: Installs the…

Node.js Read answer
Mid PDF
Explain clustering and how it improves Node.js app performance.

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. What interviewers expect A clear definition ti…

Node.js Read answer
Mid PDF
How do you scale Node.js horizontally?

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. What interviewers expect A clear defin…

Node.js Read answer
Mid PDF
How does Node.js handle concurrency? Node.js uses a single-threaded event loop to handle many I/O operations asynchronously,

Answer: llowing it to handle thousands of concurrent connections efficiently without creating threads per connection. What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (performanc…

Node.js Read answer
Mid PDF
What are some common causes of memory leaks in Node.js?

Answer: Global variables holding references. Event listeners not removed. Closures holding onto variables. Caches growing without limits. Security & Best Practices What interviewers expect A clear definition tied…

Node.js Read answer
Mid PDF
How do you update a package in 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 ins…

Node.js Read answer
Mid PDF
How do you prevent Denial of Service (DoS) attacks in 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. What interviewers expect A clear definition tied to Node.…

Node.js Read answer
Mid PDF
How do you create a custom Node.js module? You can create a custom module by writing logic in a separate .js file and exporting it using module.exports. 📌 Example: mathUtils.js function add(a, b) { return a + b; } function subtract(a, b) { return a - b; } module.exports = { add, subtract };

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

Node.js Read answer

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

  • 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

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

sync queues (e.g., with libraries like async.queue) allow you to:

  • Control concurrency (limit how many async tasks run simultaneously).
  • Queue tasks and process them in order.

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

Permalink & share

Node.js Node.js Tutorial · Node.js

  • Use monitoring tools like New Relic, Datadog, AppDynamics, or open-source tools

like Prometheus + Grafana.

  • Track metrics: response time, CPU/memory usage, error rates.
  • Use Node.js built-in profilers or clinic.js to analyze performance.
  • Set up alerts for anomalies.
Permalink & share

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

}
  • In Sequelize (MySQL/PostgreSQL):
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

Permalink & share

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.

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

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.

Permalink & share

Node.js Node.js Tutorial · Node.js

Node.js searches in this order:

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

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.

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

Global objects are available in all modules without the need to import them. Examples

include:

  • __dirname: Directory name of the current module
  • __filename: Full path of the current module
  • global: Similar to window in browsers
  • process: Provides info about the current Node.js process
  • setTimeout, setInterval, etc.
Permalink & share

Node.js Node.js Tutorial · Node.js

  • Always hash passwords before storing (never store plaintext).
  • Use strong, slow hashing algorithms like bcrypt, argon2, or scrypt.
  • Add a salt to each password (bcrypt does this automatically).
  • Use libraries like bcrypt:
const bcrypt = require('bcrypt');
const hash = await bcrypt.hash(password, 10);
  • When verifying:
const match = await bcrypt.compare(inputPassword, storedHash);

Database Integration

Permalink & share

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.

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

Answer: const EventEmitter = require('events'); const emitter = new EventEmitter(); emitter.on('greet', (name) => { console.log(`Hello, ${name}!`); }); emitter.emit('greet', 'Alice'); // Output: Hello, Alice!

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

Local Installation (default):

Installs the package into the node_modules folder of your current project.

npm install lodash

  • ✅ Used when the package is needed as part of your app's code.

Global Installation:

Installs the package system-wide, making it available in the command line anywhere.

npm install -g nodemon

  • ✅ Used for tools/CLI apps like nodemon, eslint, typescript, etc.
Permalink & share

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.

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

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.

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

Answer: llowing it to handle thousands of concurrent connections efficiently without creating threads per connection.

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

Answer: Global variables holding references. Event listeners not removed. Closures holding onto variables. Caches growing without limits. Security & Best Practices

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

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.

Permalink & share

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.

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

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

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