# What is Node.js? JavaScript on the Server Explained

Before we understand Node.js first we have to understand one important thing that JavaScript was not made for server. Yes, today we are using JavaScript everywhere but before Node.js JavaScript was only inside the browser.

When JavaScript first comes, its main work was to make webpage interactive. Like button click, popup show, changing color, form validation and small small things. Browser was the only place where JavaScript can run because browser already have JavaScript Engine inside it.

At that time if we want backend then mostly people use PHP, Java, .NET and other backend language. JavaScript was treated like a frontend only language.

For example.

HTML was for structure.  
CSS was for design.  
JavaScript was for browser interaction.

Server side was fully different world.

![](https://cdn.hashnode.com/uploads/covers/67f49df6abbd36031384c89e/ba44d043-37f4-487e-a819-cfcfd1faba10.png align="center")

Now here one interesting problem comes. Developers have to learn different language for frontend and backend both. Frontend in JavaScript and backend in PHP or Java. Because of this codebase and development process become slow and little messy also.

Then Node.js comes into the picture.

Node.js is a JavaScript Runtime Environment which allows JavaScript to run outside the browser specially on server.

Simple meaning is this.

JavaScript language already existed. Node.js did not create JavaScript. Node.js only gives environment where JavaScript can run on server machine.

Many beginners think Node.js is a programming language but actually it is not. JavaScript is language and Node.js is runtime.

Like car engine and fuel relation. Fuel alone cannot move car. Engine needed. Same JavaScript need runtime to execute. Browser have runtime and Node.js also have runtime.

![](https://cdn.hashnode.com/uploads/covers/67f49df6abbd36031384c89e/6cbb691e-11c8-4b48-a9b1-b6ce0387945b.png align="center")

Now question is how Node.js run JavaScript outside browser?

For this Node.js uses V8 Engine.

V8 Engine is created by Google for Chrome browser. Its work is converting JavaScript code into machine code so computer can understand it fastly.

Ryan Dahl who created Node.js thought one thing.

"If browser can run JavaScript using V8 then why not server?"

Then he takes V8 Engine and combines it with server side features like file handling, networking, API handling and many more things. This is how Node.js born.

![](https://cdn.hashnode.com/uploads/covers/67f49df6abbd36031384c89e/7b184e44-a08d-4a51-89c1-37018d716ef2.png align="center")

One more reason why Node.js become very popular is Event Driven Architecture.

Now don't get scared from the name. Idea is simple.

Traditional backend server mostly works one by one. If one task takes time then other task waits. But Node.js works differently.

Node.js uses non blocking approach. Means if one user request is taking time like database fetch then Node.js not sit idle. It starts handling another request.

Because of this Node.js becomes very fast for realtime applications.

For example chat app.

Suppose thousands of people sending message together. Node.js can handle these requests very efficiently because it is event driven and asynchronous.

This is one big reason companies started adopting Node.js very fastly.

Before Node.js many companies use PHP or Java backend. Those are powerful but handling realtime communication was more heavy compared to Node.js setup.

Node.js made JavaScript full stack language. Means same language on frontend and backend both. Developers loved this idea because now one language can handle complete application.

Real world use cases of Node.js are everywhere now.

Chat Applications  
Realtime Notification Systems  
Streaming Apps  
REST APIs  
Online Gaming Servers  
Collaboration Apps like Google Docs type systems  
Backend for Mobile Apps

Companies like Netflix, PayPal and LinkedIn also used Node.js because it handles high traffic and realtime communication very nicely.

One important thing.

Node.js is not replacement of every backend technology. Java, Go, PHP, Python all still important. Every technology have different strength. But Node.js become famous because it solves realtime and fast I/O problems in a simple way using JavaScript.

So in simple words.

JavaScript was earlier limited to browser only. Node.js breaks this limitation and allows JavaScript to run on server using V8 Engine and server side APIs. Because of this developers can build complete application using only JavaScript.
