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 51–75 of 123

Career & HR topics

By tech stack

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
Junior PDF
What is dotenv and how is it used?

Answer: dotenv is a library to load environment variables from a .env file into process.env. What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (performance, maintainability, secur…

Node.js Read answer
Junior PDF
What is test coverage and how do you measure it?

Test coverage shows how much of your code is tested (lines, branches, functions). Tools to measure: Istanbul/nyc: Most popular coverage tool. Jest: Has built-in coverage reports. Run coverage with nyc: nyc mocha It outpu…

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
Junior PDF
What is the role of nodemon?

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 What inter…

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
Junior PDF
What is the difference between synchronous and asynchronous functions?

Synchronous functions block the execution until they finish. Asynchronous functions allow other code to run while waiting for operations (like I/O) to complete. // Synchronous (blocks event loop) const data = fs.readFile…

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
Junior PDF
What is the purpose of the main field in package.json?

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. What interviewers expect A clear definition tied to Node.js in Node.js proj…

Node.js Read answer
Junior PDF
What is CI/CD and how can it be applied to a Node.js project?

CI/CD stands for Continuous Integration and Continuous Deployment. CI: Automatically build and test your Node.js app every time you push code (e.g., GitHub Actions, Jenkins). CD: Automatically deploy the app to productio…

Node.js Read answer
Junior PDF
What is the util.promisify() function? util.promisify() converts traditional Node.js callback-style functions into functions that return promises — letting you use async/await with them. const util = require('util'); const fs = require('fs'); const readFile = util.promisify(fs.readFile);

Answer: sync function read() { const content = await readFile('file.txt', 'utf8'); console.log(content); } What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (performance, maintain…

Node.js Read answer
Junior PDF
What is process in 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 ex…

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
Junior PDF
What is the difference between spawn() and exec()?

Both create child processes, but: spawn() streams data (good for large outputs) exec() buffers data (good for small outputs) const { spawn, exec } = require('child_process'); // spawn example const ls = spawn('ls', ['-lh…

Node.js Read answer
Junior PDF
What is the use of __dirname and __filename?

__dirname: Returns the directory path of the current module. __filename: Returns the full file path of the current module. 📌 Example: console.log(__dirname); // /Users/yourname/project console.log(__filename); // /Users…

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
Junior PDF
What is the EventEmitter class in Node.js?

Answer: EventEmitter is a core class that allows objects to emit named events and register listeners to respond. What interviewers expect A clear definition tied to Node.js in Node.js projects Trade-offs (performance, ma…

Node.js Read answer
Junior PDF
What is NPM?

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

Node.js Read answer
Junior PDF
What is event loop blocking, and how do you detect it?

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). What intervie…

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

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: dotenv is a library to load environment variables from a .env file into process.env.

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

Test coverage shows how much of your code is tested (lines, branches, functions).

Tools to measure:

  • Istanbul/nyc: Most popular coverage tool.
  • Jest: Has built-in coverage reports.

Run coverage with nyc:

nyc mocha

It outputs stats like:

  • % of lines covered
  • % of functions covered
  • % of branches covered

Security in Node.js

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: 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

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

  • Synchronous functions block the execution until they finish.
  • Asynchronous functions allow other code to run while waiting for operations (like

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

});

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

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.

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

CI/CD stands for Continuous Integration and Continuous Deployment.

  • CI: Automatically build and test your Node.js app every time you push code (e.g.,

GitHub Actions, Jenkins).

  • CD: Automatically deploy the app to production or staging after tests pass.

Benefits:

  • Catch bugs early
  • Fast, repeatable releases
  • Automated testing and deployment pipelines

Typical pipeline steps:

Permalink & share

Node.js Node.js Tutorial · Node.js

Answer: sync function read() { const content = await readFile('file.txt', 'utf8'); console.log(content); }

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

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

});

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

Both create child processes, but:

  • spawn() streams data (good for large outputs)
  • exec() buffers data (good for small outputs)
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));
Permalink & share

Node.js Node.js Tutorial · Node.js

  • __dirname: Returns the directory path of the current module.
  • __filename: Returns the full file path of the current module.

📌 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

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: EventEmitter is a core class that allows objects to emit named events and register listeners to respond.

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

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:

  • Manages package versions
  • Handles dependencies
  • Supports scripts to automate tasks (npm run build, npm test, etc.)
Permalink & share

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

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