What is Node.js?
More details in the official Node.js docs - About Node.js
Node.js is a JavaScript runtime outside the browser, built on Google Chrome's V8 engine. It lets you run JavaScript code on the server, not just in the browser.
Core characteristics
- Runtime Node.js is not a language or a framework, it is the environment in which JS code runs.
- The V8 engine Node.js is built on the V8 engine, written in C++, which compiles JavaScript into machine code for high execution speed.
- Single-threaded with non-blocking I/O Node.js runs in a single thread but efficiently handles thousands of requests at once thanks to asynchrony and the event loop.
- Modularity
It uses the CommonJS module system (
require,module.exports) and ES modules (import,export). - The npm package manager Node.js ships with npm (Node Package Manager), the largest repository of JavaScript libraries.
Uses of Node.js
- Building web servers (for example with Express.js, NestJS, Fastify)
- Building REST APIs and GraphQL APIs
- Building real-time applications (chats, online games, notifications)
- CLI tools and automation scripts
- SSR (Server-Side Rendering) for React, Next.js and others
- Microservices and backend logic
A simple HTTP server in Node.js
javascript
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello from Node.js!');
});
server.listen(3000, () => {
console.log('Server running on http://localhost:3000');
});Key advantages
- High performance (V8 + non-blocking I/O)
- Simple to work with JSON and REST
- One language - JavaScript on the client and the server
- A large npm package ecosystem
- Support for microservice and event-driven architectures
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.