Node.js Interview Master

Master Backend Excellence with 200+ Curated Node.js Questions

0 / 200 LearnedEvent Loop & V8Security & Scalability
Showing 200 results in All Questions category.
1
What is Node.js?
Beginner

Node.js is a cross-platform, open-source JavaScript runtime environment that executes JavaScript code outside a web browser. It is built on Google Chr...

Comprehensive Answer:

Node.js is a cross-platform, open-source JavaScript runtime environment that executes JavaScript code outside a web browser. It is built on Google Chrome's V8 JavaScript engine.

Copy Text Beginner
2
Is Node.js single-threaded?
Beginner

Yes, Node.js is primarily single-threaded for its event loop, but it uses internal worker threads (via libuv) for handling expensive I/O operations li...

Comprehensive Answer:

Yes, Node.js is primarily single-threaded for its event loop, but it uses internal worker threads (via libuv) for handling expensive I/O operations like file system access or network requests.

Copy Text Beginner
3
What is the difference between Node.js and JavaScript?
Beginner

JavaScript is a programming language, whereas Node.js is a runtime environment that allows you to run JavaScript on the server side.

Comprehensive Answer:

JavaScript is a programming language, whereas Node.js is a runtime environment that allows you to run JavaScript on the server side.

Copy Text Beginner
4
What is npm?
Beginner

npm (Node Package Manager) is the default package manager for Node.js. It allows developers to share and reuse code and manage project dependencies.

Comprehensive Answer:

npm (Node Package Manager) is the default package manager for Node.js. It allows developers to share and reuse code and manage project dependencies.

Copy Text Beginner
5
What is REPL in Node.js?
Beginner

REPL stands for Read-Eval-Print Loop. It is an interactive shell that takes user inputs, executes them, and prints the result, useful for testing smal...

Comprehensive Answer:

REPL stands for Read-Eval-Print Loop. It is an interactive shell that takes user inputs, executes them, and prints the result, useful for testing small snippets of code.

Copy Text Beginner
6
What are the core modules of Node.js?
Beginner

Core modules include 'fs' (file system), 'http' (creating servers), 'path' (handling file paths), 'os' (operating system info), and 'events' (event em...

Comprehensive Answer:

Core modules include 'fs' (file system), 'http' (creating servers), 'path' (handling file paths), 'os' (operating system info), and 'events' (event emitters).

Copy Text Beginner
7
How do you create a simple server in Node.js?
Beginner

Using the 'http' module: `http.createServer((req, res) => { res.end('Hello'); }).listen(3000);`

Comprehensive Answer:

Using the 'http' module: `http.createServer((req, res) => { res.end('Hello'); }).listen(3000);`

Copy Text Beginner
8
What is the role of 'package.json'?
Beginner

It is the manifest file for a Node.js project. It contains metadata about the project, script definitions, and lists of dependencies and devDependenci...

Comprehensive Answer:

It is the manifest file for a Node.js project. It contains metadata about the project, script definitions, and lists of dependencies and devDependencies.

Copy Text Beginner
9
What is the difference between `require` and `import`?
Beginner

`require` is CommonJS syntax used in Node.js by default. `import` is ES6 module syntax. Node.js supports both, but ES6 requires `.mjs` extension or `"...

Comprehensive Answer:

`require` is CommonJS syntax used in Node.js by default. `import` is ES6 module syntax. Node.js supports both, but ES6 requires `.mjs` extension or `"type": "module"` in package.json.

Copy Text Beginner
10
What is a callback function?
Beginner

A callback is a function passed as an argument to another function, which is executed after some operation (usually asynchronous) is completed.

Comprehensive Answer:

A callback is a function passed as an argument to another function, which is executed after some operation (usually asynchronous) is completed.

Copy Text Beginner
11
What is the Event Loop in Node.js?
Beginner

The Event Loop is a mechanism that allows Node.js to perform non-blocking I/O operations by offloading tasks to the system kernel whenever possible.

Comprehensive Answer:

The Event Loop is a mechanism that allows Node.js to perform non-blocking I/O operations by offloading tasks to the system kernel whenever possible.

Copy Text Beginner
12
What is the difference between `setImmediate()` and `setTimeout()`?
Beginner

`setImmediate()` is designed to execute a script once the current poll phase completes. `setTimeout()` schedules a script to be run after a minimum th...

Comprehensive Answer:

`setImmediate()` is designed to execute a script once the current poll phase completes. `setTimeout()` schedules a script to be run after a minimum threshold in ms has elapsed.

Copy Text Beginner
13
What is the purpose of `module.exports`?
Beginner

It is used to define what a module exports so that it can be used in other files using `require()`.

Comprehensive Answer:

It is used to define what a module exports so that it can be used in other files using `require()`.

Copy Text Beginner
14
What is `process.argv`?
Beginner

It is an array containing the command-line arguments passed when the Node.js process was launched.

Comprehensive Answer:

It is an array containing the command-line arguments passed when the Node.js process was launched.

Copy Text Beginner
15
Explain 'Non-blocking I/O'.
Beginner

It means that Node.js doesn't wait for an I/O operation (like reading a file) to finish before moving to the next task. Instead, it provides a callbac...

Comprehensive Answer:

It means that Node.js doesn't wait for an I/O operation (like reading a file) to finish before moving to the next task. Instead, it provides a callback.

Copy Text Beginner
16
What is the `fs` module?
Beginner

The `fs` (File System) module allows you to interact with the file system on your computer (reading, writing, deleting files).

Comprehensive Answer:

The `fs` (File System) module allows you to interact with the file system on your computer (reading, writing, deleting files).

Copy Text Beginner
17
What is 'Callback Hell'?
Beginner

It occurs when multiple nested callbacks make the code hard to read and maintain. It's often solved using Promises or Async/Await.

Comprehensive Answer:

It occurs when multiple nested callbacks make the code hard to read and maintain. It's often solved using Promises or Async/Await.

Copy Text Beginner
18
What is a Promise?
Beginner

A Promise is an object representing the eventual completion (or failure) of an asynchronous operation and its resulting value.

Comprehensive Answer:

A Promise is an object representing the eventual completion (or failure) of an asynchronous operation and its resulting value.

Copy Text Beginner
19
What is Async/Await?
Beginner

It is a syntactic sugar built on top of Promises that allows you to write asynchronous code that looks and behaves like synchronous code.

Comprehensive Answer:

It is a syntactic sugar built on top of Promises that allows you to write asynchronous code that looks and behaves like synchronous code.

Copy Text Beginner
20
What is Global Object in Node.js?
Beginner

Unlike the browser's `window` object, Node.js has a `global` object. Common globals include `process`, `__dirname`, and `__filename`.

Comprehensive Answer:

Unlike the browser's `window` object, Node.js has a `global` object. Common globals include `process`, `__dirname`, and `__filename`.

Copy Text Beginner
21
Explain `__dirname` and `__filename`.
Beginner

`__dirname` is the directory name of the current module. `__filename` is the absolute path of the current module file.

Comprehensive Answer:

`__dirname` is the directory name of the current module. `__filename` is the absolute path of the current module file.

Copy Text Beginner
22
What is the use of 'path' module?
Beginner

The 'path' module provides utilities for working with file and directory paths (e.g., `path.join()`, `path.extname()`).

Comprehensive Answer:

The 'path' module provides utilities for working with file and directory paths (e.g., `path.join()`, `path.extname()`).

Copy Text Beginner
23
What is 'error-first callback'?
Beginner

It is a pattern where the first argument of a callback is an error object (if any), and the second argument is the result data.

Comprehensive Answer:

It is a pattern where the first argument of a callback is an error object (if any), and the second argument is the result data.

Copy Text Beginner
24
How do you install a specific version of a package?
Beginner

Using `npm install <package>@<version>` (e.g., `npm install express@4.17.1`).

Comprehensive Answer:

Using `npm install <package>@<version>` (e.g., `npm install express@4.17.1`).

Copy Text Beginner
25
What is the difference between `dependencies` and `devDependencies`?
Beginner

`dependencies` are required for the application to run. `devDependencies` are only needed for development and testing (e.g., nodemon, jest).

Comprehensive Answer:

`dependencies` are required for the application to run. `devDependencies` are only needed for development and testing (e.g., nodemon, jest).

Copy Text Beginner
26
What is 'nodemon'?
Beginner

Nodemon is a tool that automatically restarts the Node.js application when file changes in the directory are detected.

Comprehensive Answer:

Nodemon is a tool that automatically restarts the Node.js application when file changes in the directory are detected.

Copy Text Beginner
27
What is 'event-driven' programming?
Beginner

It is a paradigm where the flow of the program is determined by events such as user actions, sensor outputs, or messages from other programs.

Comprehensive Answer:

It is a paradigm where the flow of the program is determined by events such as user actions, sensor outputs, or messages from other programs.

Copy Text Beginner
28
What is an EventEmitter?
Beginner

A class in the 'events' module used to handle custom events. You can 'emit' events and 'listen' for them using `.on()`.

Comprehensive Answer:

A class in the 'events' module used to handle custom events. You can 'emit' events and 'listen' for them using `.on()`.

Copy Text Beginner
29
What is a Buffer in Node.js?
Beginner

A Buffer is a way to handle binary data in Node.js, specifically used to deal with streams of binary data.

Comprehensive Answer:

A Buffer is a way to handle binary data in Node.js, specifically used to deal with streams of binary data.

Copy Text Beginner
30
What is the purpose of `os` module?
Beginner

The `os` module provides operating system-related utility methods like `os.platform()`, `os.cpus()`, and `os.totalmem()`.

Comprehensive Answer:

The `os` module provides operating system-related utility methods like `os.platform()`, `os.cpus()`, and `os.totalmem()`.

Copy Text Beginner
31
What is 'Stream' in Node.js?
Beginner

Streams are objects that let you read data from a source or write data to a destination in a continuous fashion.

Comprehensive Answer:

Streams are objects that let you read data from a source or write data to a destination in a continuous fashion.

Copy Text Beginner
32
Name the types of Streams in Node.js.
Beginner

Four types: Readable, Writable, Duplex (both read/write), and Transform (modify data while reading/writing).

Comprehensive Answer:

Four types: Readable, Writable, Duplex (both read/write), and Transform (modify data while reading/writing).

Copy Text Beginner
33
What is 'piping' in streams?
Beginner

Piping is a mechanism to connect the output of a readable stream directly to the input of a writable stream (e.g., `src.pipe(dest)`).

Comprehensive Answer:

Piping is a mechanism to connect the output of a readable stream directly to the input of a writable stream (e.g., `src.pipe(dest)`).

Copy Text Beginner
34
What is 'Chaining' in Node.js?
Beginner

Chaining is a mechanism to connect multiple stream operations together (e.g., pipe to zip, then pipe to write file).

Comprehensive Answer:

Chaining is a mechanism to connect multiple stream operations together (e.g., pipe to zip, then pipe to write file).

Copy Text Beginner
35
What is the use of `util.promisify()`?
Beginner

It is a utility that takes a function following the common error-first callback style and returns a version that returns a promise.

Comprehensive Answer:

It is a utility that takes a function following the common error-first callback style and returns a version that returns a promise.

Copy Text Beginner
36
What is 'Express.js'?
Beginner

Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.

Comprehensive Answer:

Express is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications.

Copy Text Beginner
37
What is 'Middleware' in Express?
Beginner

Middleware functions are functions that have access to the request object (req), the response object (res), and the next middleware function in the ap...

Comprehensive Answer:

Middleware functions are functions that have access to the request object (req), the response object (res), and the next middleware function in the application’s request-response cycle.

Copy Text Beginner
38
How do you handle routing in Express?
Beginner

Using `app.get()`, `app.post()`, `app.put()`, `app.delete()` etc., or using `express.Router()` for modular routes.

Comprehensive Answer:

Using `app.get()`, `app.post()`, `app.put()`, `app.delete()` etc., or using `express.Router()` for modular routes.

Copy Text Beginner
39
What is 'body-parser'?
Beginner

Initially a separate middleware, now built into Express (`express.json()`). It parses incoming request bodies in a middleware before your handlers.

Comprehensive Answer:

Initially a separate middleware, now built into Express (`express.json()`). It parses incoming request bodies in a middleware before your handlers.

Copy Text Beginner
40
What is 'REST API'?
Beginner

REST (Representational State Transfer) is an architectural style for designing networked applications using standard HTTP methods.

Comprehensive Answer:

REST (Representational State Transfer) is an architectural style for designing networked applications using standard HTTP methods.

Copy Text Beginner
41
What is 'JSON'?
Beginner

JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read/write and easy for machines to parse/genera...

Comprehensive Answer:

JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read/write and easy for machines to parse/generate.

Copy Text Beginner
42
Explain `cors` package.
Beginner

`cors` is a Node.js package for providing a Connect/Express middleware that can be used to enable CORS (Cross-Origin Resource Sharing) with various op...

Comprehensive Answer:

`cors` is a Node.js package for providing a Connect/Express middleware that can be used to enable CORS (Cross-Origin Resource Sharing) with various options.

Copy Text Beginner
43
What is `dotenv`?
Beginner

`dotenv` is a zero-dependency module that loads environment variables from a `.env` file into `process.env`.

Comprehensive Answer:

`dotenv` is a zero-dependency module that loads environment variables from a `.env` file into `process.env`.

Copy Text Beginner
44
What is 'Mongoose'?
Beginner

Mongoose is an Object Data Modeling (ODM) library for MongoDB and Node.js. It manages relationships between data, provides schema validation, etc.

Comprehensive Answer:

Mongoose is an Object Data Modeling (ODM) library for MongoDB and Node.js. It manages relationships between data, provides schema validation, etc.

Copy Text Beginner
45
What is 'JWT'?
Beginner

JWT (JSON Web Token) is a compact, URL-safe means of representing claims to be transferred between two parties.

Comprehensive Answer:

JWT (JSON Web Token) is a compact, URL-safe means of representing claims to be transferred between two parties.

Copy Text Beginner
46
How to handle file uploads in Node.js?
Beginner

Commonly using libraries like 'multer' which handles 'multipart/form-data'.

Comprehensive Answer:

Commonly using libraries like 'multer' which handles 'multipart/form-data'.

Copy Text Beginner
47
What is 'Bcrypt' used for?
Beginner

Bcrypt is a library used to hash passwords securely before storing them in a database.

Comprehensive Answer:

Bcrypt is a library used to hash passwords securely before storing them in a database.

Copy Text Beginner
48
What is 'Validation' in Node.js API?
Beginner

Checking if the input data meets certain criteria (e.g., email format, required fields). Libraries like 'Joi' or 'express-validator' are common.

Comprehensive Answer:

Checking if the input data meets certain criteria (e.g., email format, required fields). Libraries like 'Joi' or 'express-validator' are common.

Copy Text Beginner
49
What is the difference between `null` and `undefined` in JS?
Beginner

`undefined` means a variable has been declared but has not yet been assigned a value. `null` is an assignment value representing no value.

Comprehensive Answer:

`undefined` means a variable has been declared but has not yet been assigned a value. `null` is an assignment value representing no value.

Copy Text Beginner
50
What is 'Hoisting'?
Beginner

Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their containing scope before code execution.

Comprehensive Answer:

Hoisting is a JavaScript mechanism where variables and function declarations are moved to the top of their containing scope before code execution.

Copy Text Beginner
51
Explain the Event Loop phases.
Experience

Phases include: Timers (setTimeout), Pending Callbacks, Idle/Prepare, Poll (incoming I/O), Check (setImmediate), and Close Callbacks.

Comprehensive Answer:

Phases include: Timers (setTimeout), Pending Callbacks, Idle/Prepare, Poll (incoming I/O), Check (setImmediate), and Close Callbacks.

Copy Text Experience
52
What are 'Microtasks' and 'Macrotasks'?
Experience

Microtasks (process.nextTick, Promises) run after the current operation finishes and before the next Event Loop phase. Macrotasks (setTimeout, setImme...

Comprehensive Answer:

Microtasks (process.nextTick, Promises) run after the current operation finishes and before the next Event Loop phase. Macrotasks (setTimeout, setImmediate) run in specific phases of the Event Loop.

Copy Text Experience
53
What is `process.nextTick()`?
Experience

`process.nextTick()` adds a callback to the 'next tick queue'. This queue is processed after the current operation completes, regardless of the curren...

Comprehensive Answer:

`process.nextTick()` adds a callback to the 'next tick queue'. This queue is processed after the current operation completes, regardless of the current phase of the event loop.

Copy Text Experience
54
How does Node.js handle concurrency?
Experience

Node.js uses an event-driven, non-blocking I/O model. It uses a single thread to handle many connections concurrently by offloading I/O to the kernel/...

Comprehensive Answer:

Node.js uses an event-driven, non-blocking I/O model. It uses a single thread to handle many connections concurrently by offloading I/O to the kernel/worker pool.

Copy Text Experience
55
Explain 'Clustering' in Node.js.
Experience

The 'cluster' module allows you to create child processes (workers) that share the same server port, enabling your app to use all available CPU cores.

Comprehensive Answer:

The 'cluster' module allows you to create child processes (workers) that share the same server port, enabling your app to use all available CPU cores.

Copy Text Experience
56
What is 'Worker Threads' module?
Experience

The `worker_threads` module enables the use of threads that execute JavaScript in parallel, useful for CPU-intensive tasks without blocking the event ...

Comprehensive Answer:

The `worker_threads` module enables the use of threads that execute JavaScript in parallel, useful for CPU-intensive tasks without blocking the event loop.

Copy Text Experience
57
Difference between Cluster and Worker Threads?
Experience

Cluster creates separate instances of the entire Node.js process (different memory). Worker threads run in the same process and share memory (via Shar...

Comprehensive Answer:

Cluster creates separate instances of the entire Node.js process (different memory). Worker threads run in the same process and share memory (via SharedArrayBuffer).

Copy Text Experience
58
How to handle memory leaks in Node.js?
Experience

Using heap dumps, Chrome DevTools, and monitoring tools to find growing objects that aren't being garbage collected (e.g., global variables, forgotten...

Comprehensive Answer:

Using heap dumps, Chrome DevTools, and monitoring tools to find growing objects that aren't being garbage collected (e.g., global variables, forgotten timers).

Copy Text Experience
59
Explain 'Backpressure' in Streams.
Experience

Backpressure occurs when data is written to a stream faster than it can be consumed. Node.js handles this by pausing the readable stream when the writ...

Comprehensive Answer:

Backpressure occurs when data is written to a stream faster than it can be consumed. Node.js handles this by pausing the readable stream when the writable buffer is full.

Copy Text Experience
60
What is 'libuv'?
Experience

Libuv is a multi-platform C library that provides support for asynchronous I/O based on event loops. It handles the thread pool, file system, and netw...

Comprehensive Answer:

Libuv is a multi-platform C library that provides support for asynchronous I/O based on event loops. It handles the thread pool, file system, and network I/O in Node.js.

Copy Text Experience
61
How to secure a Node.js API?
Experience

Using 'helmet' for security headers, rate limiting, data validation, avoiding 'eval()', keeping dependencies updated, and using HTTPS.

Comprehensive Answer:

Using 'helmet' for security headers, rate limiting, data validation, avoiding 'eval()', keeping dependencies updated, and using HTTPS.

Copy Text Experience
62
Explain 'authentication' vs 'authorization'.
Experience

Authentication is verifying who a user is (e.g., login). Authorization is verifying what a user is allowed to do (e.g., access levels).

Comprehensive Answer:

Authentication is verifying who a user is (e.g., login). Authorization is verifying what a user is allowed to do (e.g., access levels).

Copy Text Experience
63
How to scale Node.js applications?
Experience

Horizontal scaling (adding more servers/instances with Load Balancers) and Vertical scaling (adding more CPU/RAM).

Comprehensive Answer:

Horizontal scaling (adding more servers/instances with Load Balancers) and Vertical scaling (adding more CPU/RAM).

Copy Text Experience
64
What is 'PM2'?
Experience

PM2 is a production process manager for Node.js applications. It provides features like auto-restart, cluster mode, and monitoring.

Comprehensive Answer:

PM2 is a production process manager for Node.js applications. It provides features like auto-restart, cluster mode, and monitoring.

Copy Text Experience
65
Explain 'Socket.io'.
Experience

Socket.io is a library that enables real-time, bi-directional, and event-based communication between the browser and the server.

Comprehensive Answer:

Socket.io is a library that enables real-time, bi-directional, and event-based communication between the browser and the server.

Copy Text Experience
66
What is 'Redis' used for in Node.js?
Experience

Redis is an in-memory data store commonly used as a cache, session store, or message broker to improve performance.

Comprehensive Answer:

Redis is an in-memory data store commonly used as a cache, session store, or message broker to improve performance.

Copy Text Experience
67
Explain 'Stub', 'Mock', and 'Spy' in testing.
Experience

Spy: tracks calls to a function. Stub: replaces a function with a version that returns fixed data. Mock: fake object with pre-programmed expectations.

Comprehensive Answer:

Spy: tracks calls to a function. Stub: replaces a function with a version that returns fixed data. Mock: fake object with pre-programmed expectations.

Copy Text Experience
68
How to perform 'Graceful Shutdown'?
Experience

Listening for SIGTERM/SIGINT signals, stopping the server from accepting new requests, and finishing existing ones before exiting.

Comprehensive Answer:

Listening for SIGTERM/SIGINT signals, stopping the server from accepting new requests, and finishing existing ones before exiting.

Copy Text Experience
69
Explain 'Domain-Driven Design' (DDD) in Node.js.
Experience

An approach to software development that centers the design on a core domain model, fostering a common language between tech and business.

Comprehensive Answer:

An approach to software development that centers the design on a core domain model, fostering a common language between tech and business.

Copy Text Experience
70
What is 'Microservices Architecture'?
Experience

Designing an application as a collection of small, independent services that communicate over APIs (e.g., via HTTP or RabbitMQ).

Comprehensive Answer:

Designing an application as a collection of small, independent services that communicate over APIs (e.g., via HTTP or RabbitMQ).

Copy Text Experience
71
How to handle distributed tracing?
Experience

Using tools like OpenTelemetry, Jaeger, or Zipkin to track requests as they move across different microservices.

Comprehensive Answer:

Using tools like OpenTelemetry, Jaeger, or Zipkin to track requests as they move across different microservices.

Copy Text Experience
72
Explain 'Event Sourcing'.
Experience

A pattern where the state of the application is determined by a sequence of events, rather than just the current state in a DB.

Comprehensive Answer:

A pattern where the state of the application is determined by a sequence of events, rather than just the current state in a DB.

Copy Text Experience
73
What is 'CQRS'?
Experience

Command Query Responsibility Segregation—splitting read operations (Queries) and write operations (Commands) into different models.

Comprehensive Answer:

Command Query Responsibility Segregation—splitting read operations (Queries) and write operations (Commands) into different models.

Copy Text Experience
74
How to optimize expensive database queries?
Experience

Adding indexes, using projections (selecting only needed fields), pagination, and caching results in Redis.

Comprehensive Answer:

Adding indexes, using projections (selecting only needed fields), pagination, and caching results in Redis.

Copy Text Experience
75
Explain 'Hydration' in Node.js SSR.
Experience

The process of making statically rendered HTML interactive on the client side by attaching event listeners.

Comprehensive Answer:

The process of making statically rendered HTML interactive on the client side by attaching event listeners.

Copy Text Experience
76
How to handle 10k connections simultaneously?
Experience

Using a Load Balancer (Nginx), horizontal scaling, and ensuring the application is stateless.

Comprehensive Answer:

Using a Load Balancer (Nginx), horizontal scaling, and ensuring the application is stateless.

Copy Text Experience
77
Explain 'Garbage Collection' in V8.
Experience

V8 uses a generational collector (Scavenge for young objects, Mark-Sweep-Compact for old objects) to reclaim memory.

Comprehensive Answer:

V8 uses a generational collector (Scavenge for young objects, Mark-Sweep-Compact for old objects) to reclaim memory.

Copy Text Experience
78
What is 'Heap' vs 'Stack' memory?
Experience

Stack is for static data (primitive values, function calls). Heap is for dynamic data (objects, arrays).

Comprehensive Answer:

Stack is for static data (primitive values, function calls). Heap is for dynamic data (objects, arrays).

Copy Text Experience
79
Explain 'Proto-Pollution' vulnerability.
Experience

A vulnerability where an attacker manipulates the `__proto__` property to inject properties into all objects in the application.

Comprehensive Answer:

A vulnerability where an attacker manipulates the `__proto__` property to inject properties into all objects in the application.

Copy Text Experience
80
How to use 'crypto' module?
Experience

Used for cryptographic operations like hashing, HMAC, encryption/decryption, and digital signatures.

Comprehensive Answer:

Used for cryptographic operations like hashing, HMAC, encryption/decryption, and digital signatures.

Copy Text Experience
81
What is 'Passport.js'?
Experience

Authentication middleware for Node.js. It supports various 'strategies' like OAuth, Local (username/password), etc.

Comprehensive Answer:

Authentication middleware for Node.js. It supports various 'strategies' like OAuth, Local (username/password), etc.

Copy Text Experience
82
How to handle large file uploads to S3?
Experience

Using 'multipart upload' and 'presigned URLs' to allow the client to upload directly to S3 securely.

Comprehensive Answer:

Using 'multipart upload' and 'presigned URLs' to allow the client to upload directly to S3 securely.

Copy Text Experience
83
Explain 'serverless' with Node.js.
Experience

Deploying individual functions (Lambdas) that run in response to events, without managing the underlying server infrastructure.

Comprehensive Answer:

Deploying individual functions (Lambdas) that run in response to events, without managing the underlying server infrastructure.

Copy Text Experience
84
What is 'Cold Start' in Serverless?
Experience

The delay that occurs when a serverless function is triggered for the first time or after a period of inactivity.

Comprehensive Answer:

The delay that occurs when a serverless function is triggered for the first time or after a period of inactivity.

Copy Text Experience
85
Explain 'GRPC'.
Experience

A high-performance RPC framework that uses Protocol Buffers and HTTP/2 for efficient cross-service communication.

Comprehensive Answer:

A high-performance RPC framework that uses Protocol Buffers and HTTP/2 for efficient cross-service communication.

Copy Text Experience
86
What is 'GraphQL'?
Experience

A query language for APIs that allows clients to request exactly the data they need and nothing more.

Comprehensive Answer:

A query language for APIs that allows clients to request exactly the data they need and nothing more.

Copy Text Experience
87
Difference between GraphQL and REST?
Experience

REST has multiple endpoints and can suffer from over-fetching/under-fetching. GraphQL has a single endpoint and flexible queries.

Comprehensive Answer:

REST has multiple endpoints and can suffer from over-fetching/under-fetching. GraphQL has a single endpoint and flexible queries.

Copy Text Experience
88
How to implement 'pagination' correctly?
Experience

Using 'offset-based' or 'cursor-based' (preferred for large data) pagination to limit result sizes.

Comprehensive Answer:

Using 'offset-based' or 'cursor-based' (preferred for large data) pagination to limit result sizes.

Copy Text Experience
89
Explain 'Bull' or 'Bee-Queue'.
Experience

Redis-based message queue libraries used for handling background jobs and asynchronous tasks in Node.js.

Comprehensive Answer:

Redis-based message queue libraries used for handling background jobs and asynchronous tasks in Node.js.

Copy Text Experience
90
How to use 'child_process' module?
Experience

Provides the ability to spawn child processes using `spawn`, `fork`, `exec`, or `execFile`.

Comprehensive Answer:

Provides the ability to spawn child processes using `spawn`, `fork`, `exec`, or `execFile`.

Copy Text Experience
91
Difference between `spawn` and `exec`?
Experience

`spawn` returns a stream (better for large data). `exec` buffers the entire output in memory (simpler but limited to a few MBs).

Comprehensive Answer:

`spawn` returns a stream (better for large data). `exec` buffers the entire output in memory (simpler but limited to a few MBs).

Copy Text Experience
92
What is 'N-API'?
Experience

A stable API for building native Node.js addons that is independent of the underlying JavaScript engine version.

Comprehensive Answer:

A stable API for building native Node.js addons that is independent of the underlying JavaScript engine version.

Copy Text Experience
93
How to handle 'unhandledRejection' and 'uncaughtException'?
Experience

By adding listeners to the `process` object to log the error and crash/restart gracefully.

Comprehensive Answer:

By adding listeners to the `process` object to log the error and crash/restart gracefully.

Copy Text Experience
94
Explain 'Dependency Injection' (DI).
Experience

A design pattern where an object receives its dependencies from the outside rather than creating them itself, improving testability.

Comprehensive Answer:

A design pattern where an object receives its dependencies from the outside rather than creating them itself, improving testability.

Copy Text Experience
95
What is 'Inversion of Control' (IoC)?
Experience

A principle where the control of object creation and lifecycle is shifted from the programmer to a framework/container.

Comprehensive Answer:

A principle where the control of object creation and lifecycle is shifted from the programmer to a framework/container.

Copy Text Experience
96
How to implement 'Rate Limiting'?
Experience

Using `express-rate-limit` or a custom Redis-based store to track and limit requests per IP.

Comprehensive Answer:

Using `express-rate-limit` or a custom Redis-based store to track and limit requests per IP.

Copy Text Experience
97
What is 'Log Rotation'?
Experience

The practice of periodically archiving and deleting old log files to prevent them from consuming too much disk space.

Comprehensive Answer:

The practice of periodically archiving and deleting old log files to prevent them from consuming too much disk space.

Copy Text Experience
98
Explain 'Winston' or 'Pino'.
Experience

Powerful logging libraries for Node.js that support different log levels and transports (file, console, external services).

Comprehensive Answer:

Powerful logging libraries for Node.js that support different log levels and transports (file, console, external services).

Copy Text Experience
99
How to handle database migrations?
Experience

Using tools like `knex` or `sequelize-cli` to track and apply changes to the database schema over time.

Comprehensive Answer:

Using tools like `knex` or `sequelize-cli` to track and apply changes to the database schema over time.

Copy Text Experience
100
What is 'Circuit Breaker' pattern?
Experience

A design pattern used to prevent an application from repeatedly trying to execute an operation that's likely to fail (e.g., calling a down service).

Comprehensive Answer:

A design pattern used to prevent an application from repeatedly trying to execute an operation that's likely to fail (e.g., calling a down service).

Copy Text Experience
101
Explain V8 Engine Pipeline.
Advanced

Ignition (interpreter) generates bytecode -> TurboFan (compiler) optimizes hot code to machine code -> Orinoco (GC) reclaims memory.

Comprehensive Answer:

Ignition (interpreter) generates bytecode -> TurboFan (compiler) optimizes hot code to machine code -> Orinoco (GC) reclaims memory.

Copy Text Advanced
102
What is 'Hidden Classes' in V8?
Advanced

An optimization technique where V8 creates internal classes for objects with the same structure to allow fast property access.

Comprehensive Answer:

An optimization technique where V8 creates internal classes for objects with the same structure to allow fast property access.

Copy Text Advanced
103
Explain 'Inlining' optimization.
Advanced

V8 replaces a function call with the actual body of the function to reduce call overhead if the function is small and frequently called.

Comprehensive Answer:

V8 replaces a function call with the actual body of the function to reduce call overhead if the function is small and frequently called.

Copy Text Advanced
104
What is 'Buffer.alloc' vs 'Buffer.allocUnsafe'?
Advanced

`alloc` zeroes the memory (safe). `allocUnsafe` does not zero memory (faster but may contain old sensitive data).

Comprehensive Answer:

`alloc` zeroes the memory (safe). `allocUnsafe` does not zero memory (faster but may contain old sensitive data).

Copy Text Advanced
105
Explain 'Zero-copy' in Node.js.
Advanced

A technique to avoid unnecessary data copying between the kernel and application memory, often used in networking and file transfers.

Comprehensive Answer:

A technique to avoid unnecessary data copying between the kernel and application memory, often used in networking and file transfers.

Copy Text Advanced
106
What is 'V8 Heap Snapshot'?
Advanced

A file representing the memory distribution of a Node.js process at a specific point in time, used for memory leak analysis.

Comprehensive Answer:

A file representing the memory distribution of a Node.js process at a specific point in time, used for memory leak analysis.

Copy Text Advanced
107
Explain 'Flame Graphs'.
Advanced

A visualization tool used to analyze CPU profile data and find performance bottlenecks in your code.

Comprehensive Answer:

A visualization tool used to analyze CPU profile data and find performance bottlenecks in your code.

Copy Text Advanced
108
Deep Dive: libuv thread pool size.
Advanced

Defaults to 4. Can be increased via `UV_THREADPOOL_SIZE` for handling more simultaneous file/crypto/dns operations.

Comprehensive Answer:

Defaults to 4. Can be increased via `UV_THREADPOOL_SIZE` for handling more simultaneous file/crypto/dns operations.

Copy Text Advanced
109
What is 'Isolate' in V8?
Advanced

An Isolate is an independent instance of the V8 engine, including its own heap, garbage collector, etc.

Comprehensive Answer:

An Isolate is an independent instance of the V8 engine, including its own heap, garbage collector, etc.

Copy Text Advanced
110
Explain 'Crankshaft' (Legacy) vs 'TurboFan'.
Advanced

Crankshaft was the old JIT compiler. TurboFan is the modern replacement that handles ES6 features and optimization more effectively.

Comprehensive Answer:

Crankshaft was the old JIT compiler. TurboFan is the modern replacement that handles ES6 features and optimization more effectively.

Copy Text Advanced
111
How to write Native Addons with C++?
Advanced

Using N-API or NaN (Native Abstractions for Node.js) to bridge C++ code and the V8 engine.

Comprehensive Answer:

Using N-API or NaN (Native Abstractions for Node.js) to bridge C++ code and the V8 engine.

Copy Text Advanced
112
Explain 'SharedArrayBuffer' and 'Atomics'.
Advanced

Allow multiple threads (Workers) to share the same memory and perform atomic operations to avoid race conditions.

Comprehensive Answer:

Allow multiple threads (Workers) to share the same memory and perform atomic operations to avoid race conditions.

Copy Text Advanced
113
Deep Dive: 'Tick' process in Node.js.
Advanced

A single iteration of the event loop. The number of ticks per second is a metric of loop latency.

Comprehensive Answer:

A single iteration of the event loop. The number of ticks per second is a metric of loop latency.

Copy Text Advanced
114
What is 'Event Loop Lag'?
Advanced

The delay between when an event is scheduled and when it's actually processed. High lag indicates a blocked event loop.

Comprehensive Answer:

The delay between when an event is scheduled and when it's actually processed. High lag indicates a blocked event loop.

Copy Text Advanced
115
How to implement Custom Streams?
Advanced

By extending the `Readable`, `Writable`, or `Transform` classes and implementing the `_read`, `_write`, or `_transform` methods.

Comprehensive Answer:

By extending the `Readable`, `Writable`, or `Transform` classes and implementing the `_read`, `_write`, or `_transform` methods.

Copy Text Advanced
116
Explain 'QUIC' and 'HTTP/3' support.
Advanced

Newer protocols that reduce latency by using UDP instead of TCP, with built-in encryption and multiplexing.

Comprehensive Answer:

Newer protocols that reduce latency by using UDP instead of TCP, with built-in encryption and multiplexing.

Copy Text Advanced
117
How to handle 'BigInt' in Node.js?
Advanced

Using the `BigInt` type (e.g., `100n`) for handling integers larger than `Number.MAX_SAFE_INTEGER`.

Comprehensive Answer:

Using the `BigInt` type (e.g., `100n`) for handling integers larger than `Number.MAX_SAFE_INTEGER`.

Copy Text Advanced
118
Explain 'Shadow DOM' vs 'Virtual DOM'.
Advanced

Shadow DOM is a browser technology for encapsulation. Virtual DOM is a JavaScript library concept for UI syncing.

Comprehensive Answer:

Shadow DOM is a browser technology for encapsulation. Virtual DOM is a JavaScript library concept for UI syncing.

Copy Text Advanced
119
What is 'Tree Shaking' in Node.js production?
Advanced

Removing unused code from the final bundle during the build step using tools like Webpack or Rollup.

Comprehensive Answer:

Removing unused code from the final bundle during the build step using tools like Webpack or Rollup.

Copy Text Advanced
120
Security: 'ReDoS' (Regular Expression Denial of Service).
Advanced

An attack that exploits poorly written Regex that take exponential time to process certain strings, blocking the event loop.

Comprehensive Answer:

An attack that exploits poorly written Regex that take exponential time to process certain strings, blocking the event loop.

Copy Text Advanced
121
How to implement 'Observability'?
Advanced

Combining Metrics (Prometheus), Logs (ELK), and Traces (Tempo) to understand the internal state of the system.

Comprehensive Answer:

Combining Metrics (Prometheus), Logs (ELK), and Traces (Tempo) to understand the internal state of the system.

Copy Text Advanced
122
Explain 'Chaos Engineering' in Node.js.
Advanced

Purposely introducing failures (like killing nodes or adding latency) to test the resilience of the system.

Comprehensive Answer:

Purposely introducing failures (like killing nodes or adding latency) to test the resilience of the system.

Copy Text Advanced
123
Deep Dive: `require()` cache.
Advanced

Modules are cached after the first time they are loaded. Subsequent requires return the same instance, making them effective singletons.

Comprehensive Answer:

Modules are cached after the first time they are loaded. Subsequent requires return the same instance, making them effective singletons.

Copy Text Advanced
124
Explain 'Circular Dependencies' in Node.js.
Advanced

Occurs when Module A requires Module B, and B requires A. Node.js handles this by returning an incomplete export object from the second require.

Comprehensive Answer:

Occurs when Module A requires Module B, and B requires A. Node.js handles this by returning an incomplete export object from the second require.

Copy Text Advanced
125
How to use 'Inspector' module?
Advanced

Allows you to programmatically interact with the V8 inspector for debugging and profiling.

Comprehensive Answer:

Allows you to programmatically interact with the V8 inspector for debugging and profiling.

Copy Text Advanced
126
Explain 'Native Messaging' in Chrome Extensions via Node.
Advanced

A way for a browser extension to exchange messages with a native Node.js application installed on the user's machine.

Comprehensive Answer:

A way for a browser extension to exchange messages with a native Node.js application installed on the user's machine.

Copy Text Advanced
127
What is 'JIT' (Just In Time) Compilation?
Advanced

A method of improving performance of interpreted programs by compiling code into machine language at runtime.

Comprehensive Answer:

A method of improving performance of interpreted programs by compiling code into machine language at runtime.

Copy Text Advanced
128
How to implement 'Multi-tenant' architecture?
Advanced

Using separate databases per tenant, separate schemas, or a discriminator column in shared tables.

Comprehensive Answer:

Using separate databases per tenant, separate schemas, or a discriminator column in shared tables.

Copy Text Advanced
129
Explain 'Atomic' commits with MongoDB/Node.
Advanced

Using 'Transactions' (since Mongo 4.0) to ensure multiple operations either all succeed or all fail.

Comprehensive Answer:

Using 'Transactions' (since Mongo 4.0) to ensure multiple operations either all succeed or all fail.

Copy Text Advanced
130
How to handle 'Thundering Herd' problem?
Advanced

Using 'Coalescing' (e.g., via `dataloader`) to ensure that multiple identical requests for the same resource only trigger one DB/API call.

Comprehensive Answer:

Using 'Coalescing' (e.g., via `dataloader`) to ensure that multiple identical requests for the same resource only trigger one DB/API call.

Copy Text Advanced
131
What is 'Symlink' in Node.js modules?
Advanced

A symbolic link to a file or directory. Node.js resolves these differently depending on the `--preserve-symlinks` flag.

Comprehensive Answer:

A symbolic link to a file or directory. Node.js resolves these differently depending on the `--preserve-symlinks` flag.

Copy Text Advanced
132
Explain 'Module Wrapper' in Node.js.
Advanced

Node.js wraps every module in a function: `(function(exports, require, module, __filename, __dirname) { ... })` before executing it.

Comprehensive Answer:

Node.js wraps every module in a function: `(function(exports, require, module, __filename, __dirname) { ... })` before executing it.

Copy Text Advanced
133
Difference between `exports` and `module.exports`?
Advanced

`exports` is a reference to `module.exports`. If you assign a new value to `exports`, it no longer references `module.exports`, causing no exports.

Comprehensive Answer:

`exports` is a reference to `module.exports`. If you assign a new value to `exports`, it no longer references `module.exports`, causing no exports.

Copy Text Advanced
134
How to handle 'Zlib' for compression?
Advanced

Using the `zlib` module to compress/decompress buffers and streams using Gzip, Deflate, or Brotli.

Comprehensive Answer:

Using the `zlib` module to compress/decompress buffers and streams using Gzip, Deflate, or Brotli.

Copy Text Advanced
135
Explain 'Pre-parsing' in V8.
Advanced

V8 lazily parses functions only when they are needed, performing a quick 'pre-parse' first to check for syntax errors.

Comprehensive Answer:

V8 lazily parses functions only when they are needed, performing a quick 'pre-parse' first to check for syntax errors.

Copy Text Advanced
136
What is 'Code Cache'?
Advanced

V8 caches the generated bytecode for scripts to speed up subsequent loads of the same script.

Comprehensive Answer:

V8 caches the generated bytecode for scripts to speed up subsequent loads of the same script.

Copy Text Advanced
137
How to build 'CLI' tools with Node.js?
Advanced

Using libraries like `commander`, `yargs`, or `inquirer` and adding `#!/usr/bin/env node` to the main file.

Comprehensive Answer:

Using libraries like `commander`, `yargs`, or `inquirer` and adding `#!/usr/bin/env node` to the main file.

Copy Text Advanced
138
Explain 'TTY' module.
Advanced

Used to interact with terminal windows (e.g., checking if the app is running in a terminal via `process.stdout.isTTY`).

Comprehensive Answer:

Used to interact with terminal windows (e.g., checking if the app is running in a terminal via `process.stdout.isTTY`).

Copy Text Advanced
139
What is 'Vm' module?
Advanced

Allows compiling and running code within V8 Virtual Machine contexts. Not a security sandbox!

Comprehensive Answer:

Allows compiling and running code within V8 Virtual Machine contexts. Not a security sandbox!

Copy Text Advanced
140
How to implement 'A/B Testing' server-side?
Advanced

Assigning users to groups based on their ID hash and serving different logic/routes accordingly.

Comprehensive Answer:

Assigning users to groups based on their ID hash and serving different logic/routes accordingly.

Copy Text Advanced
141
Explain 'Service Discovery' in Microservices.
Advanced

How services find each other's locations (IP/Port) in a dynamic network, using tools like Consul or Kubernetes DNS.

Comprehensive Answer:

How services find each other's locations (IP/Port) in a dynamic network, using tools like Consul or Kubernetes DNS.

Copy Text Advanced
142
What is 'API Gateway' pattern?
Advanced

A single entry point for all clients that routes requests to internal microservices, handles auth, and optionally aggregates data.

Comprehensive Answer:

A single entry point for all clients that routes requests to internal microservices, handles auth, and optionally aggregates data.

Copy Text Advanced
143
Explain 'Sidecar' pattern.
Advanced

Deploying a helper service (like a proxy or logger) alongside the main application container.

Comprehensive Answer:

Deploying a helper service (like a proxy or logger) alongside the main application container.

Copy Text Advanced
144
How to handle 'Semantic Versioning' (SemVer)?
Advanced

Following the `MAJOR.MINOR.PATCH` format to communicate breaking changes, features, and bug fixes.

Comprehensive Answer:

Following the `MAJOR.MINOR.PATCH` format to communicate breaking changes, features, and bug fixes.

Copy Text Advanced
145
What is 'NPM Audit'?
Advanced

A command that checks for known security vulnerabilities in your project's dependencies.

Comprehensive Answer:

A command that checks for known security vulnerabilities in your project's dependencies.

Copy Text Advanced
146
Explain 'Peer Dependencies'.
Advanced

Dependencies that a package requires the HOST application to provide, common in plugin development.

Comprehensive Answer:

Dependencies that a package requires the HOST application to provide, common in plugin development.

Copy Text Advanced
147
How to use 'AbortSignal' across multiple async tasks?
Advanced

Passing the same `signal` to multiple fetch/timer calls so they all cancel when the `controller.abort()` is called.

Comprehensive Answer:

Passing the same `signal` to multiple fetch/timer calls so they all cancel when the `controller.abort()` is called.

Copy Text Advanced
148
What is 'Top-level Await'?
Advanced

Support for using `await` at the top level of ES modules without being inside an `async` function.

Comprehensive Answer:

Support for using `await` at the top level of ES modules without being inside an `async` function.

Copy Text Advanced
149
Explain 'WebAssembly' (Wasm) with Node.js.
Advanced

Loading and running high-performance binary code (compiled from C++/Rust) inside the Node.js runtime.

Comprehensive Answer:

Loading and running high-performance binary code (compiled from C++/Rust) inside the Node.js runtime.

Copy Text Advanced
150
How to implement 'Data Masking' for PII?
Advanced

Obfuscating sensitive information (like Credit Card numbers) before logging or displaying it to unauthorized users.

Comprehensive Answer:

Obfuscating sensitive information (like Credit Card numbers) before logging or displaying it to unauthorized users.

Copy Text Advanced
151
Read a file and count words.
Beginner

Use fs.readFile or streams.

Comprehensive Answer:

Use fs.readFile or streams.

Code Snippet:
const fs = require('fs');
fs.readFile('test.txt', 'utf8', (err, data) => {
  const words = data.split(/\s+/).length;
  console.log(words);
});
Copy Text Programming
152
Create a basic HTTP server.
Beginner

Use the http module.

Comprehensive Answer:

Use the http module.

Code Snippet:
const http = require('http');
http.createServer((req, res) => {
  res.writeHead(200);
  res.end('Hello Node!');
}).listen(3000);
Copy Text Programming
153
Get all files in a directory.
Beginner

Use fs.readdir.

Comprehensive Answer:

Use fs.readdir.

Code Snippet:
const fs = require('fs');
fs.readdir('./', (err, files) => {
  console.log(files);
});
Copy Text Programming
154
Convert callback-based fs.readFile to Promise.
Experience

Manual promise or util.promisify.

Comprehensive Answer:

Manual promise or util.promisify.

Code Snippet:
const fs = require('fs').promises;
async function read() {
  const data = await fs.readFile('f.txt', 'utf8');
  return data;
}
Copy Text Programming
155
Implement a simple EventEmitter.
Experience

Create a custom class extender.

Comprehensive Answer:

Create a custom class extender.

Code Snippet:
const EventEmitter = require('events');
const myEmitter = new EventEmitter();
myEmitter.on('test', () => console.log('OK'));
myEmitter.emit('test');
Copy Text Programming
156
How to parse JSON from body in vanilla Node?
Experience

Accumulate chunks of data.

Comprehensive Answer:

Accumulate chunks of data.

Code Snippet:
let body = '';
req.on('data', chunk => body += chunk);
req.on('end', () => {
  const data = JSON.parse(body);
});
Copy Text Programming
157
Implement basic authentication middleware in Express.
Experience

Check headers for auth token.

Comprehensive Answer:

Check headers for auth token.

Code Snippet:
const auth = (req, res, next) => {
  if(req.headers.auth === 'secret') next();
  else res.status(401).send();
};
Copy Text Programming
158
Calculate file hash (SHA-256).
Experience

Use crypto module and streams.

Comprehensive Answer:

Use crypto module and streams.

Code Snippet:
const crypto = require('crypto');
const hash = crypto.createHash('sha256');
stream.on('data', data => hash.update(data));
Copy Text Programming
159
Pipe a file to response (download).
Beginner

Create readable stream and pipe to res.

Comprehensive Answer:

Create readable stream and pipe to res.

Code Snippet:
fs.createReadStream('file.pdf').pipe(res);
Copy Text Programming
160
Merge two objects in JS.
Beginner

Spread operator or Object.assign.

Comprehensive Answer:

Spread operator or Object.assign.

Code Snippet:
const merged = { ...obj1, ...obj2 };
Copy Text Programming
161
Check if a path is a directory or file.
Beginner

Use fs.stat and .isDirectory().

Comprehensive Answer:

Use fs.stat and .isDirectory().

Code Snippet:
fs.stat('path', (err, stats) => {
  console.log(stats.isDirectory());
});
Copy Text Programming
162
How to run multiple promises in parallel?
Experience

Use Promise.all().

Comprehensive Answer:

Use Promise.all().

Code Snippet:
await Promise.all([task1(), task2()]);
Copy Text Programming
163
Implement a Delay function.
Beginner

Return a promise that resolves after N ms.

Comprehensive Answer:

Return a promise that resolves after N ms.

Code Snippet:
const delay = ms => new Promise(res => setTimeout(res, ms));
Copy Text Programming
164
Find unique values in array.
Beginner

Use Set.

Comprehensive Answer:

Use Set.

Code Snippet:
const unique = [...new Set(arr)];
Copy Text Programming
165
Get current platform and CPU count.
Beginner

Use os module.

Comprehensive Answer:

Use os module.

Code Snippet:
const os = require('os');
console.log(os.platform(), os.cpus().length);
Copy Text Programming
166
Zip a file using zlib.
Experience

Pipe read stream -> createGzip -> write stream.

Comprehensive Answer:

Pipe read stream -> createGzip -> write stream.

Code Snippet:
fs.createReadStream('file.txt')
  .pipe(zlib.createGzip())
  .pipe(fs.createWriteStream('file.txt.gz'));
Copy Text Programming
167
How to catch unhandled promise rejections?
Experience

process listener.

Comprehensive Answer:

process listener.

Code Snippet:
process.on('unhandledRejection', (err) => {
  console.error(err);
});
Copy Text Programming
168
Implement a basic Cluster worker logic.
Experience

Check cluster.isMaster and fork.

Comprehensive Answer:

Check cluster.isMaster and fork.

Code Snippet:
if (cluster.isPrimary) cluster.fork();
else http.createServer(...).listen(80);
Copy Text Programming
169
Filter an array of objects by property.
Beginner

Array.filter.

Comprehensive Answer:

Array.filter.

Code Snippet:
const users = list.filter(u => u.age > 18);
Copy Text Programming
170
Format currency in JS.
Beginner

Intl.NumberFormat.

Comprehensive Answer:

Intl.NumberFormat.

Code Snippet:
new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }).format(100);
Copy Text Programming
171
Generate a random token string.
Experience

Use crypto.randomBytes.

Comprehensive Answer:

Use crypto.randomBytes.

Code Snippet:
crypto.randomBytes(32).toString('hex');
Copy Text Programming
172
Check if a variable is an array.
Beginner

Array.isArray().

Comprehensive Answer:

Array.isArray().

Code Snippet:
Array.isArray(myVar);
Copy Text Programming
173
Implement a simple LRU cache (Logic).
Advanced

Use a Map to track usage order.

Comprehensive Answer:

Use a Map to track usage order.

Code Snippet:
cache.delete(key); cache.set(key, value);
Copy Text Programming
174
How to handle timeouts in Fetch?
Experience

AbortController with setTimeout.

Comprehensive Answer:

AbortController with setTimeout.

Code Snippet:
setTimeout(() => controller.abort(), 5000);
Copy Text Programming
175
Convert string to base64.
Beginner

Buffer.from().toString('base64').

Comprehensive Answer:

Buffer.from().toString('base64').

Code Snippet:
Buffer.from('hello').toString('base64');
Copy Text Programming
176
Group array of objects by a key.
Experience

Reduce into an object.

Comprehensive Answer:

Reduce into an object.

Code Snippet:
arr.reduce((acc, obj) => {
  (acc[obj.key] = acc[obj.key] || []).push(obj);
  return acc;
}, {});
Copy Text Programming
177
How to execute a shell command?
Beginner

child_process.exec.

Comprehensive Answer:

child_process.exec.

Code Snippet:
exec('ls', (err, stdout) => console.log(stdout));
Copy Text Programming
178
Check if a string is a valid JSON.
Beginner

Try-catch JSON.parse.

Comprehensive Answer:

Try-catch JSON.parse.

Code Snippet:
try { JSON.parse(str); return true; } catch { return false; }
Copy Text Programming
179
Implement a custom Writable stream.
Advanced

Implement _write method.

Comprehensive Answer:

Implement _write method.

Code Snippet:
class MyW extends Writable {
  _write(chunk, enc, next) { ... next(); }
}
Copy Text Programming
180
Find the intersection of two arrays.
Beginner

Filter and Includes.

Comprehensive Answer:

Filter and Includes.

Code Snippet:
arr1.filter(x => arr2.includes(x));
Copy Text Programming
181
How to detect a memory leak in a simple loop?
Advanced

Continuously add items to a global array.

Comprehensive Answer:

Continuously add items to a global array.

Code Snippet:
setInterval(() => leaks.push(new Array(100000)), 100);
Copy Text Programming
182
Debounce a function (Generic).
Experience

Timeout closure.

Comprehensive Answer:

Timeout closure.

Code Snippet:
return (...args) => {
  clearTimeout(t);
  t = setTimeout(() => f(...args), ms);
};
Copy Text Programming
183
Throttle a function (Generic).
Experience

Flag based execution.

Comprehensive Answer:

Flag based execution.

Code Snippet:
if(!wait) { f(); wait = true; setTimeout(()=>wait=false, ms); }
Copy Text Programming
184
Deep clone an object (using structuredClone).
Beginner

Native modern JS method.

Comprehensive Answer:

Native modern JS method.

Code Snippet:
const copy = structuredClone(original);
Copy Text Programming
185
Implement a queue using two stacks.
Advanced

Push to S1, Pop from S2 (filling from S1 when empty).

Comprehensive Answer:

Push to S1, Pop from S2 (filling from S1 when empty).

Code Snippet:
enqueue(x) { s1.push(x) }
Copy Text Programming
186
Check for prime numbers.
Beginner

Standard math loop.

Comprehensive Answer:

Standard math loop.

Code Snippet:
for(let i=2; i < n; i++) if(n%i===0) return false;
Copy Text Programming
187
Reverse words in a sentence.
Beginner

Split, reverse, join.

Comprehensive Answer:

Split, reverse, join.

Code Snippet:
s.split(' ').reverse().join(' ');
Copy Text Programming
188
Find the median of an array.
Experience

Sort and pick middle.

Comprehensive Answer:

Sort and pick middle.

Code Snippet:
const s = arr.sort((a,b)=>a-b); return s[len/2];
Copy Text Programming
189
Convert epoch to human readable date.
Beginner

new Date(ms).

Comprehensive Answer:

new Date(ms).

Code Snippet:
new Date(1600000000 * 1000).toLocaleString();
Copy Text Programming
190
Implement a retry logic for fetch.
Experience

Loop with try-catch and delay.

Comprehensive Answer:

Loop with try-catch and delay.

Code Snippet:
for(let i=0; i<3; i++) try { return fetch(); } catch { await delay(); }
Copy Text Programming
191
Flatten nested JSON.
Advanced

Recursive key concatenation.

Comprehensive Answer:

Recursive key concatenation.

Code Snippet:
const flat = (o, p) => ... o[p + key] = val;
Copy Text Programming
192
How to get query params from URL in Node?
Beginner

Use url module or URL class.

Comprehensive Answer:

Use url module or URL class.

Code Snippet:
const params = new URL(req.url, 'http://x').searchParams;
Copy Text Programming
193
Capitalize first letter of string.
Beginner

Slice and toUpperCase.

Comprehensive Answer:

Slice and toUpperCase.

Code Snippet:
s[0].toUpperCase() + s.slice(1);
Copy Text Programming
194
Count occurrences of characters in string.
Beginner

Reduce into object.

Comprehensive Answer:

Reduce into object.

Code Snippet:
s.split('').reduce((a,c) => { a[c] = (a[c]||0)+1; return a; }, {});
Copy Text Programming
195
Write a stream-based file copy function.
Beginner

Pipe read to write stream.

Comprehensive Answer:

Pipe read to write stream.

Code Snippet:
fs.createReadStream('a').pipe(fs.createWriteStream('b'));
Copy Text Programming
196
Find the first non-repeating character.
Experience

Frequency count and find index.

Comprehensive Answer:

Frequency count and find index.

Code Snippet:
const char = s.split('').find(c => s.indexOf(c) === s.lastIndexOf(c));
Copy Text Programming
197
Implement Binary Search.
Experience

Midpoint comparison in sorted array.

Comprehensive Answer:

Midpoint comparison in sorted array.

Code Snippet:
while(l <= r) { m = (l+r)/2; if(arr[m] === t) ... }
Copy Text Programming
198
How to use worker threads for heavy math?
Advanced

Spawn worker and listen for message.

Comprehensive Answer:

Spawn worker and listen for message.

Code Snippet:
const worker = new Worker('./math.js'); worker.postMessage(n);
Copy Text Programming
199
Implement a simple string template engine.
Experience

Regex replace with object keys.

Comprehensive Answer:

Regex replace with object keys.

Code Snippet:
s.replace(/{{(\w+)}}/g, (m, k) => obj[k]);
Copy Text Programming
200
Check if two strings are anagrams.
Beginner

Sort and compare.

Comprehensive Answer:

Sort and compare.

Code Snippet:
sort(s1) === sort(s2);
Copy Text Programming

Become a Node.js Expert

Join 10,000+ developers getting deep dives into V8 internals and microservices.