Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: How do they differ? process.nextTick() queues a callback to be invoked immediately after the current operation completes, before the event loop continues. setImmediate() queues a callback to run on the next…
Short answer: Deploying means getting your app from your local machine to a live server. Explain a bit more Basic steps: Choose a hosting platform: VPS (DigitalOcean, AWS EC2), PaaS (Heroku, Vercel), or container platfor…
Short answer: You typically use the MongoDB Node.js driver or an ODM like Mongoose. Explain a bit more Basic connection example with native driver: const { MongoClient } = require('mongodb'); async function connect() { c…
Short answer: Unit tests check small, isolated pieces of your code (like functions) to make sure they work as expected. Explain a bit more Basic example using Mocha and Chai: // calculator.js function add(a, b) { return…
Short answer: Node.js runs on a single thread by default, which means it can handle only one operation at a time per process. Clustering allows you to create multiple Node.js processes (workers) that share the same serve…
Short answer: process.nextTick() queues a callback to be invoked immediately after the current operation completes, before the event loop continues. Explain a bit more setImmediate() queues a callback to run on the next…
Short answer: If an error (exception) is thrown but not caught, Node.js will: Print the error stack trace to the console. Explain a bit more Immediately terminate the process to avoid unpredictable behavior. Why? Because…
Short answer: sync function connect() { const uri = 'mongodb://localhost:27017/mydatabase'; const client = new MongoClient(uri); try { wait client.connect(); console.log('Connected to MongoDB'); const db = client.db('myd…
Short answer: Injection attacks (SQL, NoSQL) Cross-Site Scripting (XSS) Cross-Site Request Forgery (CSRF) Broken authentication and session management Insecure handling of sensitive data (passwords, API keys) Unvalidated…
Short answer: s expected. Basic example using Mocha and Chai: // calculator.js function add(a, b) { return a + b; } module.exports = add; // test/calculator.test.js const add = require('../calculator'); const { expect }…
Short answer: time per process. Clustering allows you to create multiple Node.js processes (workers) that share the same server port. This way, your app can utilize multiple CPU cores and handle more requests concurrentl…
Short answer: Node.js is an open-source, cross-platform runtime environment that allows you to run JavaScript on the server side. It’s built on the V8 JavaScript engine developed by Google (the same one used in Chrome).…
Short answer: How do you create and use custom events? EventEmitter allows objects to emit named events and listen for them. Example: const EventEmitter = require('events'); const emitter = new EventEmitter(); emitter.on…
Short answer: EventEmitter allows objects to emit named events and listen for them. Example code const EventEmitter = require('events'); const emitter = new EventEmitter(); emitter.on('greet', (name) => { console.log(…
Short answer: Node.js uses a single-threaded event loop to handle concurrency. Explain a bit more This design: Simplifies programming by avoiding thread-related bugs like race conditions. Uses non-blocking I/O so a singl…
Short answer: Process management means keeping your app running reliably, restarting it if it crashes, and managing multiple instances. PM2 is a popular Node.js process manager that: Restarts apps on crashes or code chan…
Short answer: Mongoose is an ODM (Object Data Modeling) library for MongoDB in Node.js. It provides: Schema-based data modeling Validation Middleware (hooks) Easy querying and relationship management You define schemas a…
Short answer: Always use parameterized queries or prepared statements instead of string concatenation. Example with MySQL: connection.query('SELECT * FROM users WHERE id = ?', [userId], callback); Use ORM libraries like…
Short answer: Mocha: Flexible test runner, widely used. Jest: Full-featured, zero-config, includes mocks and coverage. Jasmine: Behavior-driven development framework. AVA: Minimalistic and fast. Tape: Simple and small fo…
Short answer: Use clustering or process managers like PM2 to utilize multiple CPU cores. Explain a bit more Implement caching (in-memory or distributed caches like Redis). Use asynchronous I/O properly (avoid blocking th…
Short answer: Use Azure Policy to enforce resource rules. Store secrets in Azure Key Vault. Implement role-based access control (RBAC) for all resources. Enable Azure Security Center for continuous monitoring. Real-world…
Short answer: PI system? Azure App Service or Azure Kubernetes Service (AKS) for hosting APIs. Azure API Management for gateway and throttling. Cosmos DB with partitioned throughput for high-speed data. Azure Cache for R…
Short answer: Azure App Service or Azure Kubernetes Service (AKS) for hosting APIs. Azure API Management for gateway and throttling. Cosmos DB with partitioned throughput for high-speed data. Azure Cache for Redis for fr…
Short answer: pps? Database latency or unoptimized queries. Blocking synchronous calls instead of async patterns. Memory or CPU constraints on App Service Plan. Excessive cold starts in serverless functions. Poor caching…
Short answer: Database latency or unoptimized queries. Blocking synchronous calls instead of async patterns. Memory or CPU constraints on App Service Plan. Excessive cold starts in serverless functions. Poor caching stra…
Node.js Node.js Tutorial · Node.js
Short answer: How do they differ? process.nextTick() queues a callback to be invoked immediately after the current operation completes, before the event loop continues. setImmediate() queues a callback to run on the next iteration of the event loop.
process.nextTick(() => console.log('nextTick')); setImmediate(() => console.log('setImmediate')); console.log('sync'); Output: sync nextTick setImmediate nextTick runs before any I/O or timers; setImmediate runs after I/O callbacks.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: Deploying means getting your app from your local machine to a live server.
Basic steps: Choose a hosting platform: VPS (DigitalOcean, AWS EC2), PaaS (Heroku, Vercel), or container platforms (Kubernetes, Docker). Set environment variables securely (don't hardcode secrets). Install dependencies using npm install --production. Run your app with a process manager (like PM2) for stability. Set up reverse proxy (using Nginx or Apache) to handle HTTPS, load balancing, and static files. Automate deployments with scripts or CI/CD pipelines.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: You typically use the MongoDB Node.js driver or an ODM like Mongoose.
Basic connection example with native driver: const { MongoClient } = require('mongodb'); async function connect() { const uri = 'mongodb://localhost:27017/mydatabase'; const client = new MongoClient(uri); try { await client.connect(); console.log('Connected to MongoDB'); const db = client.db('mydatabase'); // Use `db` to query collections } catch (err) { console.error(err); } finally { await client.close(); } } connect();
You typically use the MongoDB Node.js driver or an ODM like Mongoose. Basic connection example with native driver: const { MongoClient } = require('mongodb');
async function connect() {
const uri = 'mongodb://localhost:27017/mydatabase';
const client = new MongoClient(uri); try { await client.connect(); console.log('Connected to MongoDB'); const db = client.db('mydatabase'); // Use `db` to query collections } catch (err) { console.error(err); } finally { await client.close();
}
} connect();
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: Unit tests check small, isolated pieces of your code (like functions) to make sure they work as expected.
Basic example using Mocha and Chai: // calculator.js function add(a, b) { return a + b; const { expect } = require('chai'); describe('add function', () => { it('should return the sum of two numbers', () => { const result = add(2, 3); expect(result).to.equal(5); }); }); Run tests with: mocha This test suite checks if add(2,3) equals 5 — simple and effective.
}
module.exports = add; // test/calculator.test.js const add = require('../calculator');
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: Node.js runs on a single thread by default, which means it can handle only one operation at a time per process. Clustering allows you to create multiple Node.js processes (workers) that share the same server port. This way, your app can utilize multiple CPU cores and handle more requests concurrently. 📌 Example: Using the built-in cluster module, you can fork multiple workers.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: process.nextTick() queues a callback to be invoked immediately after the current operation completes, before the event loop continues.
setImmediate() queues a callback to run on the next iteration of the event loop.
process.nextTick(() => console.log('nextTick')); setImmediate(() => console.log('setImmediate')); console.log('sync'); Output: sync nextTick setImmediate nextTick runs before any I/O or timers; setImmediate runs after I/O callbacks.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: If an error (exception) is thrown but not caught, Node.js will: Print the error stack trace to the console.
Immediately terminate the process to avoid unpredictable behavior. Why? Because an uncaught exception might leave the app in an inconsistent state. Best practice: Use try/catch for synchronous code, and listen to 'uncaughtException' or 'unhandledRejection' events to log errors and gracefully shut down: process.on('uncaughtException', (err) => { console.error('Uncaught Exception:', err); process.exit(1); // Exit to avoid unstable state });
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: sync function connect() { const uri = 'mongodb://localhost:27017/mydatabase'; const client = new MongoClient(uri); try { wait client.connect(); console.log('Connected to MongoDB'); const db = client.db('mydatabase'); // Use `db` to query collections } catch (err) { console.error(err); } finally { wait client.close(); } } connect(); Example… code sync…… function connect() { const uri =…
'mongodb://localhost:27017/mydatabase'; const client = new MongoClient(uri); try { wait client.connect(); console.log('Connected to MongoDB'); const db = client.db('mydatabase'); // Use `db` to query collections } catch (err) { console.error(err); } finally { wait client.close(); } } connect(); sync function connect() { const uri = 'mongodb://localhost:27017/mydatabase'; const client = new MongoClient(uri); try { wait client.connect(); console.log('Connected to MongoDB'); const db = client.db('mydatabase'); // Use `db` to query collections } catch (err) { console.error(err); } finally { wait client.close(); } } connect(); Example… code sync function…
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: Injection attacks (SQL, NoSQL) Cross-Site Scripting (XSS) Cross-Site Request Forgery (CSRF) Broken authentication and session management Insecure handling of sensitive data (passwords, API keys) Unvalidated input data Exposed stack traces or error messages Security misconfigurations
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: s expected. Basic example using Mocha and Chai: // calculator.js function add(a, b) { return a + b; } module.exports = add; // test/calculator.test.js const add = require('../calculator'); const { expect } = require('chai'); describe('add function', () => { it('should return the sum of two numbers', () => { const result = add(2, 3);… Explain a… bit more s…… expected. Basic example using Mocha and Chai: //…
calculator.js function add(a, b) { return a + b; } module.exports = add; // test/calculator.test.js const add = require('../calculator'); const { expect } = require('chai'); describe('add function', () => { it('should return the sum of two numbers', () => { const result = add(2, 3); expect(result).to.equal(5); }); }); Run tests with: mocha This test suite checks if add(2,3) equals 5 — simple and effective. s expected. Basic example using Mocha and Chai: // calculator.js function add(a, b) { return a + b; } module.exports = add; // test/calculator.test.js const add = require('../calculator'); const { expect } =… s expected. Basic example… }
module.exports = add; // test/calculator.test.js const add = require('../calculator');
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: time per process. Clustering allows you to create multiple Node.js processes (workers) that share the same server port. This way, your app can utilize multiple CPU cores and handle more requests concurrently. 📌 Example: Using the built-in cluster module, you can fork multiple workers.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: Node.js is an open-source, cross-platform runtime environment that allows you to run JavaScript on the server side. It’s built on the V8 JavaScript engine developed by Google (the same one used in Chrome). With Node.js, you can build scalable and high-performance web applications, APIs, and even real-time services like chat apps. 📌
If you write a simple HTTP server in Node.js, you can serve a webpage without using a traditional web server like Apache: const http = require('http'); http.createServer((req, res) => { res.end('Hello from Node.js server!'); }).listen(3000);
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: How do you create and use custom events? EventEmitter allows objects to emit named events and listen for them. Example: const EventEmitter = require('events'); const emitter = new EventEmitter(); emitter.on('greet', (name) => { console.log(`Hello, ${name}!`); }); emitter.emit('greet', 'Alice'); Output: Hello, Alice! It’s fundamental for asynchronous communication in Node.js.
How do you create and use custom events? EventEmitter allows objects to emit named events and listen for them. Example: const EventEmitter = require('events');
const emitter = new EventEmitter(); emitter.on('greet', (name) => { console.log(`Hello, ${name}!`); }); emitter.emit('greet', 'Alice'); Output: Hello, Alice! It’s fundamental for asynchronous communication in Node.js.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: EventEmitter allows objects to emit named events and listen for them.
const EventEmitter = require('events'); const emitter = new EventEmitter(); emitter.on('greet', (name) => { console.log(`Hello, ${name}!`); }); emitter.emit('greet', 'Alice'); Output: Hello, Alice! const emitter = new EventEmitter(); emitter.on('greet', (name) => { console.log(`Hello, ${name}!`); }); emitter.emit('greet', 'Alice'); Output: Hello, Alice! It’s fundamental for asynchronous communication in Node.js.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: Node.js uses a single-threaded event loop to handle concurrency.
This design: Simplifies programming by avoiding thread-related bugs like race conditions. Uses non-blocking I/O so a single thread can handle many connections efficiently. Offloads heavy tasks (file I/O, network requests) to background threads in the libuv thread pool. So, Node.js can handle many tasks concurrently without spawning multiple OS threads for each.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: Process management means keeping your app running reliably, restarting it if it crashes, and managing multiple instances. PM2 is a popular Node.js process manager that: Restarts apps on crashes or code changes Manages clustering (multi-core usage) Offers logs and monitoring dashboards Supports zero-downtime reloads Run your app with PM2 like this: pm2 start app.js pm2 monit
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: Mongoose is an ODM (Object Data Modeling) library for MongoDB in Node.js. It provides: Schema-based data modeling Validation Middleware (hooks) Easy querying and relationship management You define schemas and models to interact with MongoDB more intuitively.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: Always use parameterized queries or prepared statements instead of string concatenation. Example with MySQL: connection.query('SELECT * FROM users WHERE id = ?', [userId], callback); Use ORM libraries like Sequelize which handle this automatically. Validate and sanitize inputs.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: Mocha: Flexible test runner, widely used. Jest: Full-featured, zero-config, includes mocks and coverage. Jasmine: Behavior-driven development framework. AVA: Minimalistic and fast. Tape: Simple and small footprint.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: Use clustering or process managers like PM2 to utilize multiple CPU cores.
Implement caching (in-memory or distributed caches like Redis). Use asynchronous I/O properly (avoid blocking the event loop). Optimize database queries and use connection pooling. Minimize heavy computations in the main thread (offload with worker threads). Use gzip compression for responses. Properly manage memory leaks. Use load balancers in production.
Microsoft Azure Microsoft Azure Tutorial · Azure
Short answer: Use Azure Policy to enforce resource rules. Store secrets in Azure Key Vault. Implement role-based access control (RBAC) for all resources. Enable Azure Security Center for continuous monitoring.
ShopNest on Azure typically uses App Service + SQL Database + Blob Storage + Application Insights for monitoring.
Microsoft Azure Microsoft Azure Tutorial · Azure
Short answer: PI system? Azure App Service or Azure Kubernetes Service (AKS) for hosting APIs. Azure API Management for gateway and throttling. Cosmos DB with partitioned throughput for high-speed data. Azure Cache for Redis for frequently accessed data. Use Azure Front Door / CDN for global load balancing.
ShopNest on Azure typically uses App Service + SQL Database + Blob Storage + Application Insights for monitoring.
Microsoft Azure Microsoft Azure Tutorial · Azure
Short answer: Azure App Service or Azure Kubernetes Service (AKS) for hosting APIs. Azure API Management for gateway and throttling. Cosmos DB with partitioned throughput for high-speed data. Azure Cache for Redis for frequently accessed data. Use Azure Front Door / CDN for global load balancing.
ShopNest on Azure typically uses App Service + SQL Database + Blob Storage + Application Insights for monitoring.
Microsoft Azure Microsoft Azure Tutorial · Azure
Short answer: pps? Database latency or unoptimized queries. Blocking synchronous calls instead of async patterns. Memory or CPU constraints on App Service Plan. Excessive cold starts in serverless functions. Poor caching strategy or missing CDNs.
ShopNest on Azure typically uses App Service + SQL Database + Blob Storage + Application Insights for monitoring.
Microsoft Azure Microsoft Azure Tutorial · Azure
Short answer: Database latency or unoptimized queries. Blocking synchronous calls instead of async patterns. Memory or CPU constraints on App Service Plan. Excessive cold starts in serverless functions. Poor caching strategy or missing CDNs.
ShopNest on Azure typically uses App Service + SQL Database + Blob Storage + Application Insights for monitoring.