In this page we introduce Node.js, what it does and why you would want to use it.
TODO: Add diagram JS -> JS Runtime -> Machine code
Browsers are designed to display web applications that users can interact with. These web applications run on your own personal device and are often referred to as the front-end: they are about what a user can see and interact with, much like a store front.
The opposite of the front-end is the back-end, which provides services that your front-end might need to work properly. Back-end computers are called servers because they provide a service, whereas front-end computer are called clients. This architecture is called the client-server model. Clients communicate with servers through a request-response cycle: each time the client needs something it sends a request to the server who will provide a response with the needed information.
Which applications do you know where the client-server model is used? Answer
Common tasks that servers need to perform include hosting web pages, sharing files, providing email communications, etc. These tasks require access to the file system and other interactions with the computer which browsers don't support for security reasons. This is where Node.js comes into play, it provides functionality to perform file operations and interact with your device so it can perform all the necessary operations to act as a server.
Why do web browsers not allow access to the file system? Answer
There are plenty of different types of server software available which use a wide variety of languages. So why would we choose to use a Node.js server over others?
Another good reason is that Node.js handles I/O such as file access and network connections very well. It uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. This is accomplished through the event loop:
Node.js comes with, npm, the largest ecosystem of open source libraries in the world. Many functionalities that you might need such as utility functions, process management or interacting with a database have already been made. They are published as packages on npm and you can import them in your project to get started. Don't reinvent the wheel.
fetch :) is still true! The Event Loop, Classes, Closure, Arrays, Objects, Variables,
this., it's all still the same.
Introduction to Node.js (Reading, ~10 minutes) - plus much more!