DEV Community

Cover image for Differences between Javascript and NodeJs
Maria Antonella πŸ¦‹
Maria Antonella πŸ¦‹

Posted on

Differences between Javascript and NodeJs

At first it was hard for me to understand the differences because for me, they were the same thing. It was all javascript. But then, I started to understand what each one was used for. For this reason, I share it :)

☘ JavaScript is a language that runs inside web browsers as part of the documents loaded by the browser and is used as a client-side development language. It provides the behavior of the pages. Like HTML it provides the semantic structure and CSS the look and feel.

However, being an interpreted language, it needs an interpreter to run. V8 is Google Chrome's JS engine and 'node' is a front-end that can be used to run JavaScript scripts outside the browser. In other words:

☘ NodeJs is an open source, cross-platform environment that allows you to create server-side applications and tools using JavaScript.

A short list of comparisons πŸ§πŸ’»:

JS
πŸ”΄ Can only be run in the browsers
πŸ”΄ Used on the client-side
πŸ”΄ Capable enough to add HTML and play with the DOM
Enter fullscreen mode Exit fullscreen mode
NodeJs
🟑 Can be run outside the browser
🟑 Used on the server-side.
🟑 Does not have the capability to add HTML tags
Enter fullscreen mode Exit fullscreen mode

Top comments (12)

Collapse
 
cerlancism profile image
Chen Yu • Edited

Javascript is just a programming language which can be used in any environment where a Javascript interpreter or runtime is available (noticed that I used "interpreter or runtime", as modern JS engines like V8, JS is actually compiled to bytecode rather than being actually interpreted). Welcome to the rabbit hole of JS! Browser and NodeJS are just the more common ones, there are many other environments such as Electron (Desktop Applications), React Native (Mobile Applications), MUJS etc, and these different environments define what you can do with it such as manipulating DOM or server side functions or more.

Collapse
 
machr profile image
Mark Powell

This GeekForGeeks article basically explains the same thing and it looks like you copied the comparisons from there anyway.

geeksforgeeks.org/difference-betwe...

I hope your post helps beginners though :)

Collapse
 
antoomartini profile image
Maria Antonella πŸ¦‹

Not actually, I took notes from other places. I didn't know of its existence. But I see that the link you share is more complete than mine!! There are things that I hadn't taken into account. Thank you! 😌😁

Collapse
 
hyoretsu profile image
Aran Leite • Edited

Uhm. Except JS is also run on Node. And Node's sort of a standalone V8. You also don't just "run JS in the browsers", you execute it the same way you can just pop up a node terminal and execute JS. Just like how you don't "run Node.js outside the browser" because by itself it doesn't do anything.

JS on the browser's also not more or less capable than in Node.js. The only difference is that one's in an environment that has a DOM while the other isn't.

Collapse
 
insidewhy profile image
insidewhy

You wrote that JavaScript "Can only be run in browsers"? but JavaScript runs in node, and node is not a browser.

Node also does have capabilities to add HTML tags, depending on how you look at things. Say... with SSR.

Collapse
 
sirajulm profile image
Sirajul Muneer

JS runs on both client and server.
NodeJS is just an engine made to run JS.
You are actually comparing a train to a rail track.

Some comments may only be visible to logged-in visitors. Sign in to view all comments.