All questions
Showing of 59What is the V8 engine and how does Node.js use it?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
V8 is Google's open-source JavaScript engine, written in C++, and Node.js embeds it to run JavaScript outside the browser. V8 compiles your code to bytecode, a compact instruction format that its Ignition interpreter runs. While the code runs, V8 tracks the types it sees and the shapes of objects, which it calls hidden classes. Its just-in-time (JIT) compilers then turn functions that run often into optimized machine code.
V8 also manages the heap and garbage collection, but it does no I/O itself. Node.js handles I/O through libuv, a separate C library it bundles for the event loop and the thread pool.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain the concept of non-blocking I/O in Node.js.
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Non-blocking I/O means Node.js starts an I/O operation and keeps running other code instead of waiting for it to finish. Reading a file, querying a database and calling another server all work this way. When the result is ready, the event loop runs the callback you passed, or resumes the function that awaited the promise.
// Non-blocking example
const fs = require('fs');
console.log('Start reading file');
fs.readFile('large-file.txt', (err, data) => {
console.log('File read complete');
});
console.log('This executes immediately');
// Output: Start reading file, This executes immediately, File read complete
This executes immediately prints before File read complete, because readFile returns at once and its callback runs later. The main thread never sits idle waiting on a disk or the network. That is how a single Node.js process handles thousands of concurrent connections.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What are callbacks and what is callback hell?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
A callback is a function you pass to another function, which calls it when an asynchronous operation finishes. Node.js core APIs follow the error-first convention. The first argument is an error or null, and the result comes after it.
Callback hell is the deep nesting you get when each step depends on the one before. The error check repeats at every level, which makes the code hard to read and maintain.
// Callback hell example
getData((err, data) => {
if (err) return console.error(err);
processData(data, (err, processed) => {
if (err) return console.error(err);
saveData(processed, (err, result) => {
if (err) return console.error(err);
console.log('Data saved successfully');
});
});
});
The fix is to flatten the chain. Promises and async/await turn it into a straight sequence with one place to handle errors. Splitting each step into a small named function also helps.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is the difference between module.exports and exports?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
require() returns module.exports, and exports is a reference to it: a shortcut variable that points at the same object when the module starts. Adding properties through either name works, because both point to one object. Assigning a new object to exports breaks that reference. The module still returns the original module.exports, so the new object never leaves the file.
// Method 1: Using exports (shorthand)
exports.add = (a, b) => a + b;
exports.subtract = (a, b) => a - b;
// Method 2: Using module.exports
module.exports = {
add: (a, b) => a + b,
subtract: (a, b) => a - b
};
// Method 3: Exporting a single function
module.exports = (a, b) => a + b;
// Wrong: This breaks the reference
exports = { add: (a, b) => a + b }; // Won't work
Use exports.name = value to export several named values. Use module.exports = value to export one function, class or object. The three methods above are alternatives. Mixing them in one file is a common bug, because a later module.exports assignment throws away everything added through exports.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is npm and what are npm scripts?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
npm, short for Node Package Manager, is the package manager that ships with Node.js. It installs, updates and publishes JavaScript packages. npm scripts are named commands in the scripts field of package.json, which you run with npm run <script-name>.
{
"scripts": {
"start": "node server.js",
"dev": "nodemon server.js",
"test": "jest",
"build": "webpack --mode production",
"lint": "eslint .",
"prestart": "npm run build"
}
}
Scripts give a project one shared set of commands for development, testing and production builds. npm puts the project's installed tools on the PATH, so nodemon or jest run without a global install. A pre or post script runs before or after the script with the matching name, so prestart builds before start. Scripts run in the system shell, sh or cmd.exe, so a Unix-only command fails on Windows.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
Explain package.json and package-lock.json.
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
package.json describes the project and the version ranges it accepts, while package-lock.json records the exact versions npm installed. You edit package.json yourself. It holds the project metadata and scripts, plus the dependencies and devDependencies lists.
{
"name": "my-app",
"version": "1.0.0",
"dependencies": {
"express": "^4.18.0"
},
"devDependencies": {
"nodemon": "^2.0.15"
}
}
A range like ^4.18.0 accepts any later 4.x release, so two installs months apart can differ. npm install updates the lock file whenever it changes node_modules.
The lock file maps the exact dependency tree, sub-dependencies included, with an integrity hash for each package. A tampered download then fails the check. Commit the lock file so every environment installs the same tree, and use npm ci in builds to install exactly what it lists.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you read and write files in Node.js?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Use the built-in fs module, which offers each read and write operation in three styles. The callback and promise versions hand the disk work to libuv's thread pool, a few background threads, so the server keeps answering other requests. The Sync versions block the event loop until the disk responds.
const fs = require('fs');
// Asynchronous (recommended)
fs.readFile('input.txt', 'utf8', (err, data) => {
if (err) return console.error(err);
console.log('File content:', data);
});
fs.writeFile('output.txt', 'Hello World', (err) => {
if (err) return console.error(err);
console.log('File written successfully');
});
// Synchronous (blocking)
try {
const data = fs.readFileSync('input.txt', 'utf8');
fs.writeFileSync('output.txt', data.toUpperCase());
} catch (err) {
console.error('Error:', err);
}
// Promise-based
const fsPromises = require('fs').promises;
fsPromises.readFile('input.txt', 'utf8').then((text) => console.log(text)).catch(console.error);
In server code, use an asynchronous style. The promise version also works with await inside an async function. Use the Sync calls only in startup code and command-line scripts, where blocking does not matter.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
How do you create a basic HTTP server in Node.js?
What is the difference between http and https modules?
How do you make HTTP requests in Node.js?
What is Express.js and why is it popular?
How do you handle routing in Express.js?
What is the difference between app.use() and app.get()?
How do you handle form data and JSON in Express?
How do you handle environment configuration in Node.js?
What is Node.js, and when should you use it?
Answer it yourself first - out loud, or typed below.
How should your speech become text?
Listening… your words appear above as you speak - tap Stop when you're done.
Recording · cr - tap Stop & transcribe when you're done.
Transcribing with AI…
Voice:
Last attempt -
Node.js is an open-source, cross-platform runtime that runs JavaScript outside the browser, on Google's V8 engine. It adds what a server needs and a browser lacks, such as file system access and network servers. Its model is asynchronous and event-driven. One process serves many connections on a single thread, because I/O calls do not block while they wait.
That makes Node.js a strong fit for I/O-heavy work such as APIs, chat and streaming. Teams also gain one language across the front end and the back end, and the npm ecosystem. It is a poor fit for long CPU-heavy tasks such as video encoding, because a busy thread delays every other request. Worker threads ease that, but such work often belongs in a separate service.
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.
Why there's no diagram: “”
The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓
What is middleware in Express.js?
Explain the Node.js Event Loop and how it works.
Explain Promises in Node.js with examples.
What is async/await and how does it improve asynchronous code?
How do you handle errors in asynchronous operations?
What is the difference between Promise.all() and Promise.allSettled()?
How does Node.js resolve modules?
What are Streams in Node.js and when would you use them?
Explain the difference between fs.readFile() and fs.createReadStream().
What is the Buffer class in Node.js?
Explain request and response objects in Node.js HTTP.
How do you handle errors in Express.js?
What are some common debugging techniques in Node.js?
How do you implement caching in Node.js?
What are common security vulnerabilities in Node.js applications?
How do you implement authentication and authorization?
How do you secure API endpoints?
What is input validation and how do you implement it?
How do you implement WebSockets in Node.js?
What is the EventEmitter class and how do you use it?
How do you implement database connections and ORM in Node.js?
How do you test a Node.js application?
What is the middleware pattern and how do you write custom middleware?
How do you implement pagination in Node.js APIs?
How do you deploy Node.js applications?
How do you implement real-time features with Server-Sent Events (SSE)?
What is the difference between CommonJS and ES6 modules in Node.js?
How do you handle rate limiting in Node.js applications?
Is Node.js single-threaded, and what does the libuv thread pool do?
What is the difference between child_process.spawn(), fork(), and exec()?
How do you handle uncaught exceptions and unhandled rejections?
How do you optimize performance in Node.js applications?
What is clustering in Node.js and how does it work?
What is memory management in Node.js?
What are Worker Threads in Node.js?
What are design patterns commonly used in Node.js?
What is the difference between setImmediate(), setTimeout(), and process.nextTick()?
How do you implement graceful shutdown in Node.js?
Explain memory leaks in Node.js and how to prevent them.
What is Node-API and how does it help with native addons?
How do you implement logging and monitoring in production Node.js applications?
What causes event loop lag, and how do you detect and prevent it?
What is AsyncLocalStorage, and what problem does it solve?
This answer is part of Pro.
The full written answer, with the trade-offs and follow-ups an interviewer will probe.
No matches
Try a different filter or search term.
Node.js in pictures.
A quick recap of Node.js in 32 short animated pictures, one idea at a time. About 9 min to get the whole topic back in your head before you walk in. Pause any picture, slow it down, or step through it.
Pro The first chapter is free to play. The other 28 pictures come with Pro.
Node.js cheatsheet
- How Node.js runs your code01
- Async code & its errors02
- Modules, npm & patterns03
- Buffer, files & streams04
- HTTP servers & Express05
- Security & auth06
- Data, caches & real-time07
- CPU, cores & memory08
- Test, debug & production09
- The model10
- + 4 more inside
This picture is part of Pro. The first chapter is free to play; the other 28 pictures come with Pro.
Get Pro · $10/mo Already Pro? Sign in51 of 59 Node.js answers are in Pro.
Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.
- Full answers + code
- AI explanations, simpler or deeper
- 1,000 AI credits / month
- Cancel anytime
Change topic
Pick a different technology or stack. Your current topic stays put until you choose a new one.
MEAN
MongoDB, Express, Angular, Node.jsMERN
MongoDB, Express, React, Node.jsDjango
Python Full-Stack DevelopmentRuby on Rails
Convention over ConfigurationServerless on AWS
Serverless Architecture on AWSInterviewers also test these - they're common to every stack, whichever one you picked above.
Flutter Mobile
Flutter Cross-Platform Mobile DevelopmentInterviewers also test these - they're common to every stack, whichever one you picked above.
Spring Boot
Enterprise Java Development.NET
Microsoft EcosystemVue
Vue.js, Vite, TypeScript, Tailwind, Node.jsGo Backend
Golang, gRPC, PostgreSQL, Redis, RabbitMQInterviewers also test these - they're common to every stack, whichever one you picked above.
FastAPI
Python, FastAPI, SQLAlchemy, PostgreSQLReact Native
React, TypeScript, Redux, FirebaseiOS Native
Swift, SwiftUI, UIKit, FirebaseAndroid Native
Java, Jetpack Compose, FirebaseDevOps / Platform
Docker, Kubernetes, Terraform, CI/CDInterviewers also test these - they're common to every stack, whichever one you picked above.
AI Engineer
LLMs, RAG, Agents, EvalsAI-Powered Developer
Claude Code, Copilot, Agentic WorkflowsCore SWE Interview Prep
Data structures, algorithms, OS, concurrency, networking, gitInterviewers also test these - they're common to every stack, whichever one you picked above.
Interviewers also test these - they're common to every stack, whichever one you picked above.