Before we start, we have to make it clear that NodeJS is not Javascript. As a web developers, you should learn Javascript before get into NodeJS. So, you might wonder what is NodeJS? NodeJs is not a programming language but it is a runtime environment for Javascript, an environment to run Javascript. Another important thing is to know when something is the language or part of the environment. We’ll use “setTimeout” as an example. There are a lot of developers that think that “setTimeout” is part of Javascript, but actually it isn’t. It is part of the environment.
In this article, we have list 4 things you should know when learning NodeJS.
Streams & Buffer
ArrayBuffer is part of Javascript and especially in NodeJs, streams are everywhere. We can argue that pretty much NodeJs is “built on streams”. Streams are one of the top things you should master when learning NodeJS. Most of the time, streams and buffer are inseparable. You cannot talk about streams without mentioning buffer, such as ArrayBuffer, pipe, back pressure, etc. It is also important to master all the stream types, writable, readable, transform, and duplex. The reason streams are so important in our opinion because it provide time and memory efficiency when transferring data.
Events & Event Emitters
When you start working with streams, you can’t help to notice that you listen to stream events and this is because it uses event emitters (event module) to send the various types of events like “error”, “end” and “data”.
NodeJs is built around an idiomatic asynchronous event-driven architecture where emitters run the show. So, you should learn to integrate events in your application because almost everything in Node produces events. Try to create your own events and utilize the event emitter.
Module & Architecture
Modular architecture and Modules play big part in Node. The idea that every file is a module with its own scope and you can choose what to expose or not pretty much defines NodeJs applications.
So how actually NodeJs Modules work? It works by using a function that inject global things, like exports and require to wrap the code in your file. Being aware of that, will make you understand about how communication is done, what are the limits, the importance of Events, and facilitates the building of workers and threads.
File System
Mastering file System or fs module is important because at the end of the day you will work with the server-side. You will have to read and write files and collect information from them. Which means you need the knowledge and skill to read files and directories, perform CRUD operations, and collect details. When interacting with the File System you will automatically interact with streams and events as well, which further highlights the need to learn those concepts in depth.