Node.js Basics
Node.js Introduction
Node.js is a runtime that executes JavaScript outside the browser, built on Chrome’s V8 engine. It gives JavaScript access to the file system, networking and processes, which is what makes it usable for servers, command-line tools and build tooling.
What is Introduction in Node.js?
Node.js is a runtime that executes JavaScript outside the browser, built on Chrome’s V8 engine. It gives JavaScript access to the file system, networking and processes, which is what makes it usable for servers, command-line tools and build tooling.
Why Introduction matters
Node.js lets one language cover both ends of a web application. For an Indian fresher that translates directly into MERN and MEAN stack roles, which are among the most commonly advertised full-stack job titles.
Introduction example
import { createServer } from 'node:http';
const server = createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ message: 'Hello from Node.js' }));
});
server.listen(3000, () => console.log('http://localhost:3000'));How this works
No external web server is needed — Node itself listens on the port. The callback runs for every request, and because it is asynchronous a single process can serve many connections at once.
Key points to remember
- Single-threaded for your code, but I/O runs on a thread pool behind the scenes.
- Event-driven and non-blocking, which suits I/O-heavy work such as APIs.
- npm is the largest package registry in the world.
- Not the right choice for CPU-bound work such as video encoding.
Node.js compared with browser JavaScript
| Browser | Node.js | |
|---|---|---|
| Global object | window | global / globalThis |
| DOM access | yes | no |
| File system | no | yes, via fs |
| Modules | ES modules | ES modules and CommonJS |
| Typical use | user interfaces | APIs, CLIs, build tools, real-time servers |
Common mistakes with Introduction
- Expecting document or window to exist — there is no DOM.
- Running heavy synchronous computation, which blocks every other request.
Node.js Introduction— Interview Questions & FAQs
Is Node.js a programming language?+
No. It is a runtime environment that executes JavaScript outside the browser. The language is still JavaScript; Node adds APIs for files, networking and processes.
Is Node.js good for beginners?+
Yes, if you already know JavaScript — you reuse the same language on the server. The new concepts are asynchronous I/O, modules and the npm ecosystem rather than a new syntax.
