What is NodeJS and when to use it?

As you may heard before, NodeJS is defined as “Javascript Runtime built on V8 Javascript Engine”. Even though it may look a bit complicated, let’s scrutinize the definition closer. Normally, any browser (Google Chrome, Safari, Firefox etc.) can natively understand HTML, CSS and JS codes. In this case, browsers are javascript runtimes and corresponding Javascript engines are responsible to handle the Javascript code. As we said before in the definition above, V8 Javascript Engine is developed and used by Google to use in Chrome Browser and thanks to it, we can use Javascript outside of the browsers via NodeJS since May 2009.
With the increasing popularity of JavaScript, NodeJs has become much more popular since its release date. It’s designed and developed for a purpose, and outside of that goal, it may be a wrong decision to use NodeJS in such cases like CPU intensive operations and heavy server-side processes (Heavy image manipulations, video conversion, file conversions etc.). However, when you want to develop some applications with the given below specifications, it would be a perfect choice.
- Backend, API Development
- Data Streaming
- Real-time chat applications
- Server-side web applications
Throughout this nodejs tutorial blog, we will try to develop an example API (Application Programming Interface) project with the Mongo db behind it. Before deep diving into the project, lets install node in our local device and try to get to know the Node closely.
Installment
In order to install Node environment in your local device, please visit the original NodeJS Website. By choosing the right installer file for your operating system, you can easily download and install node.
NodeJS Version Selection
As it is declared in the official NodeJs website, major Node.js versions enter Current release status for six months after the release. After the time, odd-numbered releases (9, 11, etc.) become unsupported, and even-numbered releases (10, 12, etc.) move to Active LTS (long-term support) status and are ready for general use. Thus, when you start a new project with the NodeJS environment, please prioritise to select the odd-numbered versions of Node.
Built-in Global Variables
As in every programming language, NodeJs also has various built-in Global Variables in order to ease development. In order to see the whole list of built-in global variables in node environment, you can press TAB button twice in terminal of node. By doing that, you can list all the global variables. As you may see in below One of the commonly used built-in global variable is of course console module.
Create Global Variables
We can also declare a new global variables as we need. In order to do that, we can use "global.newVariable" format. In the below image, you can see the new global variable that we defined and usage.
Please see the references and links below