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
NodeJs
π‘ Can be run outside the browser
π‘ Used on the server-side.
π‘ Does not have the capability to add HTML tags
Top comments (12)
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.
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 :)
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! ππ
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.
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.
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.