Master technical and career interviews with structured answers—short definition, real examples, pitfalls, and how to answer in 60–90 seconds.
Short answer: Node.js searches in this order: Real-world example (ShopNest) A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront. Say this in the interview Define — one clear sentence (the…
Short 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 Real…
Short 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. Real-world example (ShopNe…
Short answer: 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…
Short answer: 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…
Short answer: CSRF (Cross-Site Request Forgery) tricks a user into submitting unwanted requests to a trusted site. Protection: Use CSRF tokens with forms (e.g., csurf middleware in Express). Implement same-site cookies.…
Short answer: util.promisify() converts traditional Node.js callback-style functions into functions that return promises — letting you use async/await with them. Example code const util = require('util'); const fs = requ…
Short 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. Real-world example (ShopNest) A ShopNest BFF in Node.js aggregates ca…
Short answer: 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 ap…
Short answer: sync function read() { const content = await readFile('file.txt', 'utf8'); console.log(content); } sync function read() { const content = await readFile('file.txt', 'utf8'); console.log(content); } sync fun…
Short answer: 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…
Short answer: 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…
Short answer: 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 = spa…
Short answer: __dirname: Returns the directory path of the current module. __filename: Returns the full file path of the current module. 📌 Example code console.log(__dirname); // /Users/yourname/project console.log(__fi…
Short 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. Real-world exa…
Short answer: EventEmitter is a core class that allows objects to emit named events and register listeners to respond. Real-world example (ShopNest) A ShopNest BFF in Node.js aggregates catalog and price APIs for the Rea…
Short answer: 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…
Short 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). Real-wo…
Short answer: const EventEmitter = require('events'); const emitter = new EventEmitter(); emitter.on('greet', (name) => { console.log(`Hello, ${name}!`); }); emitter.emit('greet', 'Alice'); // Output: Hello, Alice! Ex…
Short answer: 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:…
Short answer: Express allows multiple middleware functions to run sequentially for a request. Each calls next() to pass control to the next middleware. app.use((req, res, next) => { console.log('Middleware 1'); next()…
Short answer: Clustering runs multiple Node.js instances on different CPU cores sharing the same server port. This spreads load and uses full CPU capacity, increasing concurrency. Real-world example (ShopNest) A ShopNest…
Short answer: pp.use((req, res, next) => { console.log('Middleware 1'); next(); }); pp.use((req, res, next) => { console.log('Middleware 2'); res.send('Done'); }); pp.use((req, res, next) => { console.log('Middl…
Short answer: dependencies: These are required for your app to run in production. 📌 Example code express, mongoose devDependencies: Only needed during development (testing, building, linting). 📌 Example: nodemon, eslin…
Short answer: Node.js uses a single-threaded event loop to handle many I/O operations asynchronously, allowing it to handle thousands of concurrent connections efficiently without creating threads per connection. Real-wo…
Node.js Node.js Tutorial · Node.js
Short answer: Node.js searches in this order:
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short 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
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short 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.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: 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); });
ShopNest’s Node API handles many checkout requests concurrently because I/O (DB/HTTP) is non-blocking on the event loop.
Node.js Node.js Tutorial · Node.js
Short answer: 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.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: CSRF (Cross-Site Request Forgery) tricks a user into submitting unwanted requests to a trusted site. Protection: Use CSRF tokens with forms (e.g., csurf middleware in Express). Implement same-site cookies. Require authentication on sensitive endpoints.
const csurf = require('csurf'); app.use(csurf());
Node.js Node.js Tutorial · Node.js
Short answer: 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);
async function read() {
const content = await readFile('file.txt', 'utf8'); console.log(content); }
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short 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.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: 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:
Node.js Node.js Tutorial · Node.js
Short answer: sync function read() { const content = await readFile('file.txt', 'utf8'); console.log(content); } sync function read() { const content = await readFile('file.txt', 'utf8'); console.log(content); } sync function read() { const content = await readFile('file.txt', 'utf8'); console.log(content); } sync function read() { const content = await… readFile('file.txt', 'utf8'); console.log(content); }
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 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...'); });
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 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
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: 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));
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: __dirname: Returns the directory path of the current module. __filename: Returns the full file path of the current module. 📌
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
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short 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.
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 is a core class that allows objects to emit named events and register listeners to respond.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: 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.)
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short 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).
ShopNest’s Node API handles many checkout requests concurrently because I/O (DB/HTTP) is non-blocking on the event loop.
Node.js Node.js Tutorial · Node.js
Short answer: const EventEmitter = require('events'); const emitter = new EventEmitter(); emitter.on('greet', (name) => { console.log(`Hello, ${name}!`); }); emitter.emit('greet', 'Alice'); // Output: Hello, Alice!
const EventEmitter = require('events');
const emitter = new EventEmitter(); emitter.on('greet', (name) => { console.log(`Hello, ${name}!`); }); emitter.emit('greet', 'Alice'); // Output: Hello, Alice!
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: 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.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: Express allows multiple middleware functions to run sequentially for a request. Each calls next() to pass control to the next middleware. app.use((req, res, next) => { console.log('Middleware 1'); next(); }); app.use((req, res, next) => { console.log('Middleware 2'); res.send('Done'); });
Express middleware authenticates JWT, then the /orders route handler creates the order.
Node.js Node.js Tutorial · Node.js
Short answer: Clustering runs multiple Node.js instances on different CPU cores sharing the same server port. This spreads load and uses full CPU capacity, increasing concurrency.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Node.js Node.js Tutorial · Node.js
Short answer: pp.use((req, res, next) => { console.log('Middleware 1'); next(); }); pp.use((req, res, next) => { console.log('Middleware 2'); res.send('Done'); }); pp.use((req, res, next) => { console.log('Middleware 1'); next(); }); pp.use((req, res, next) => { console.log('Middleware 2'); res.send('Done'); }); pp.use((req, res, next) => { console.log('Middleware 1');… next(); }); pp.use((req, res, next) => {…
console.log('Middleware 2'); res.send('Done'); }); pp.use((req, res, next) => { console.log('Middleware 1'); next(); }); pp.use((req, res, next) => { console.log('Middleware 2'); res.send('Done'); });
Express middleware authenticates JWT, then the /orders route handler creates the order.
Node.js Node.js Tutorial · Node.js
Short answer: dependencies: These are required for your app to run in production. 📌
express, mongoose devDependencies: Only needed during development (testing, building, linting). 📌 Example: nodemon, eslint, jest 📦 These are defined in package.json: "dependencies": { "express": "^4.18.0" }, "devDependencies": { "nodemon": "^3.0.0" } ✅ Install a dev dependency with: npm install nodemon --save-dev
Node.js Node.js Tutorial · Node.js
Short answer: Node.js uses a single-threaded event loop to handle many I/O operations asynchronously, allowing it to handle thousands of concurrent connections efficiently without creating threads per connection.
A ShopNest BFF in Node.js aggregates catalog and price APIs for the React storefront.
Install Toolliyo like an app Free
Home-screen access to tutorials, coding practice & career tools — no app store needed.
On iPhone/iPad: tap Share then Add to Home Screen.