JavaScript on the Server
How V8 Engine Powers Node.js and Makes JavaScript Universal

Introduction
We all know JavaScript as the language of the browser. But have you ever wondered how it became a part of backend development too?
At one point, JavaScript was limited to things like button clicks and animations. But with the introduction of Node.js, everything changed.
In this article, we’ll learn what a server is, how JavaScript runs on it using the V8 engine, what makes Node.js a runtime, and how to write and run our first Node.js program.
What is a Server?
A server is just a remote computer that sends data or services to other computers over the internet. For example, when you visit Google, your request goes to their server, not a physical office.

Here's how the process works:
Every website is associated with an IP address (for example, 142.250.191.14 for Google)
When you type a domain name, your computer resolves it to the corresponding IP address
Your browser sends a request to that IP address
The server processes the request and sends back the appropriate response
Your browser renders the received data
Before Node.js, web development needed two separate skill sets. Frontend developers used JavaScript for building user interfaces, while backend developers used different languages like Java, Python, or PHP for server-side work. This created a clear gap between client-side and server-side development.
Node.js changed that. It allowed JavaScript developers to write both frontend and backend code using the same language. This led to full-stack development and popular stacks like MEAN (MongoDB, Express, Angular, Node) and MERN (MongoDB, Express, React, Node).
What is an IP Address?
An IP address (Internet Protocol Address) is a unique number assigned to every device connected to the internet.

It acts like a digital address, helping data find the right destination.
Each section of an IPv4 address is called an octet, and together they form a 32-bit number.
What is the V8 Engine?
While you might assume Node.js is written in JavaScript, it's actually built using C++. This raises an important question: how can a C++ application execute JavaScript code?
What makes this possible is the V8 JavaScript engine, created by Google for the Chrome browser. It’s written in C++ and is designed to run JavaScript quickly and efficiently.
One of its best features is that it can be embedded into any C++ application. Node.js uses this feature to include V8 inside it, allowing JavaScript to run outside the browser.

The process works like this:
You write JavaScript code
Node.js (a C++ application) receives your code
The embedded V8 engine translates your JavaScript into machine code
Your computer executes the resulting machine code
ECMAScript and JS Engines
JavaScript engines like V8 (Chrome), SpiderMonkey (Firefox), Chakra (Microsoft), and JavaScriptCore (Safari) all follow a standard called ECMAScript.
ECMAScript is like a rulebook. It defines how JavaScript should behave, so that your code runs the same way across different browsers and environments.
But here’s the catch: engines like V8 only run core JavaScript. They can’t do things like:
Connect to a database
Read or write files
Make server-side API calls
That’s where Node.js comes in.
Node.js uses V8 at its heart, but also gives it extra abilities — like file system access, network requests, and databases. This mix of V8 + extra powers is what makes Node.js a runtime.
How V8 Brings Your Code to Life
V8 itself is written in C++. When you write JavaScript, it doesn’t stay in that form. V8 translates your code into machine code and assembly code, which your computer’s CPU can actually understand.
So, the flow looks like this:
You write JavaScript (high-level, human-friendly).
V8 converts it into machine instructions (low-level).
The CPU executes those instructions.
What is Low-Level Code?
Low-level code is closer to the hardware and gives direct control over system resources.
Machine Language → The most basic form, just 0s and 1s. The CPU executes it directly.
Assembly Language → A small step above machine code. Uses short mnemonics (like MOV, ADD) to represent operations, but still maps directly to machine instructions.
Thanks to V8, we don’t need to write machine or assembly code ourselves. We just write JavaScript, and V8 does the heavy lifting behind the scenes.What is a JavaScript Runtime?
What is a JavaScript Runtime?
A JavaScript Runtime is basically two things combined:
A JavaScript engine (like V8)
Plus extra features that let it work outside the browser
Inside the browser, your JavaScript can only do things like manipulate the DOM or handle user events. It can’t directly access files on your computer or talk to a database.
Node.js changes that. Along with the V8 engine, it provides built-in modules and libraries such as:
File system modules (to read and write files)
Network libraries (to handle HTTP requests)
Server APIs (to build servers easily)
Database connectors (to store and retrieve data)
So the formula becomes:
JavaScript Runtime = V8 + Node.js APIs
This combination is what makes Node.js so powerful. It takes the speed of the V8 engine and adds the tools needed for real-world backend applications.
Let’s Write Some Code
Now that we understand what Node.js is and how it works, let’s write and run our first program.
Step 1: Install Node.js
Go to the official Node.js website and download the installer for your operating system:
Step 2: Verify Installation
After installation, open your terminal and type:
node -v
npm -v
node -v shows the installed Node.js version.
npm -v shows the installed NPM (Node Package Manager) version.
If both return version numbers, Node.js has been installed successfully.
Step 3: Try the Node REPL
Type node in your terminal. This opens the REPL (Read-Evaluate-Print Loop) where you can run JavaScript interactively.
For example:
> let x = 10;
> let y = 15;
> x + y
25
The REPL is useful for quick tests, but writing everything here is not practical. Let’s move to a proper editor.
Step 4: Write Code in VS Code
Create a new folder on your computer (for example, my-node-project).
Open the folder in Visual Studio Code (VS Code).
Create a file named app.js.
Write the following code:\
let name = "My First Node App"; let a = 5; let b = 10; let c = a + b; console.log(name); console.log("Sum is:", c);Open the terminal in VS Code:
On Windows/Linux: Ctrl + Shift + `
On macOS: Command + Shift + `
Run the program:
node app.jsOutput:
My First Node App Sum is: 15
Global Objects in Node.js
In the browser, the global object is window.
In Node.js, the global object is called global.
Example:
console.log(global);
This will show methods like setTimeout, setInterval, and more.
Important note:
console.log(this); // {}
At the top level in Node.js, this does not refer to the global object.
What is globalThis?
To solve these differences across environments, ECMAScript 2020 introduced globalThis.
In browsers, globalThis refers to window.
In Node.js, globalThis refers to global.
This gives us one consistent way to access the global object, no matter where our JavaScript code is running.
Conclusion
JavaScript started as a language for browsers, but with Node.js, it expanded to the server side as well.
The V8 engine made it possible to run JavaScript outside the browser, while Node.js added the runtime features needed for real applications.
Now, developers can use a single language for both frontend and backend, making JavaScript truly universal.
From understanding servers and IP addresses to writing your first Node.js program, this is the foundation of JavaScript on the server.
In the next step, you can explore how the Node.js event loop works and how NPM helps manage packages.
Want More…?
I write articles on blog.devwithjay.com and also post development-related content on the following platforms:




