Join the AI Workshop and learn to build real-world apps with AI. A hands-on, practical program to level up your skills.
Both the browser and Node use JavaScript as their programming language.
Building apps that run in the browser is a completely different thing than building a Node.js application.
Despite the fact that it’s always JavaScript, there are some key differences that make the experience radically different.
As a frontend developer who extensively uses JavaScript, Node brings with it a huge advantage - the comfort of programming everything, the frontend and the backend, in a single language.
Using the same language on the client and the server means you can focus on one language; you do not need to learn a separate one for the backend.
What changes is the ecosystem.
In the browser, most of the time what you are doing is interacting with the DOM, or other Web Platform APIs like Cookies. Those do not exist in Node, of course. You don’t have the document, window and all the other objects that are provided by the browser.
In the browser you do not have the APIs that Node.js provides through its modules, such as filesystem access.
Another big difference is that in Node.js you control the environment. Unless you are building an open source application that anyone can deploy anywhere, you know which version of Node you will run the application on. Compared to the browser environment, where you don’t get the luxury to choose what browser your visitors will use, this is very convenient.
This means that you can write all the modern ES6-7-8-9 JavaScript that your Node version supports.
Since JavaScript moves so fast, but browsers can be a bit slow and users a bit slow to upgrade, sometimes on the web, you are stuck using older JavaScript / ECMAScript releases.
You can use Babel to transform your code to be ES5-compatible before shipping it to the browser, but in Node, you won’t need that.
Another difference is that Node has traditionally used the CommonJS module system (require()), while browsers support ES Modules (import). Node now supports ES modules as well; in practice you often use require() in Node and import in frontend code.