Node.js is a JavaScript runtime built on Chrome's V8 engine. It allows JavaScript to run outside a web browser, so you can build servers, APIs, command-line tools, automation scripts, and real-time applications.
Node.js vs JavaScript
JavaScript is the language. Node.js is the runtime that executes JavaScript and provides server-side APIs such as files, networking, processes, and environment variables.
Why learn Node.js?
- Build backend APIs.
- Use JavaScript on both frontend and backend.
- Work with npm packages.
- Build scalable I/O-heavy applications.
Deep dive
How Node.js fits into a web application
A typical web application has a frontend, a backend, and a database. The browser sends an HTTP request to the Node.js backend. Node.js runs application logic, talks to databases or external services, and sends an HTTP response back to the browser.
When Node.js is a good choice
- REST and GraphQL APIs
- Real-time communication
- Microservices
- Command-line tools
- Automation and build tooling
When to be careful
Node.js is not automatically the best choice for every workload. Long-running CPU-heavy JavaScript can block the event loop and should be designed carefully using worker threads, separate services, or another suitable architecture.
Beginner takeaway
Do not think of Node.js as a replacement for JavaScript. Think of it as the environment that gives JavaScript access to server-side capabilities.