o7planning

Introduction to NodeJs

View more Tutorials:

Follow us on our fanpages to receive notifications every time there are new articles. Facebook Twitter

1- What is NodeJs?

Before directly answering the question "What is NodeJS?", I am going to introduce you about the birth context of the NodeJS, which helps you understand the matter more easily.
Chrome & V8 Javascript Engine
Everyone knows that Chrome is a famous and free Google browser with the first version released in December 2008, of which V8 JavaScript Engine is a program written on C++, open source code, used in the Google Chrome to parse and execute Javascript code with high performance. It parses Javascript syntax and interprets it into computer code for execution.
Note: The browsers other than the Chrome may use other Javascript Engine.
Browser Javascript Engine
Chrome V8 JS Engine
Firefox SpiderMonkey
IE, Edge Chakra
NodeJS
You can use  "the syntax of Javascript" to write code snippets to connect to a database. The V8 JS Engine will parse your Javascript code and interprets it into computer code for execution. Of course, such code snippet is not for execution at the client side. it is used at the server side. Thus, an ability is opened, you can use "the Javascript syntax" to write server-side web applications instead of using PHP or Java.
** Javascript code **

const mysql = require('mysql');
const connection = mysql.createConnection({
  host: 'localhost',
  user: 'user',
  password: 'password',
  database: 'database name'
});
connection.connect((err) => {
  if (err) throw err;
  console.log('Connected!');
});
and NodeJS was born. The V8 Javascript Engine is one of components of the NodeJS. Below is the architecture image of the NodeJS:
In short, the NodeJS may replace PHP, Java to build Server-side web applications. Instead of writing code by PHP, Java you use the syntax of Javascript.
So, What is NodeJS?
The NodeJS is JavaScript Runtime Environment outside browser. The NodeJS also consists of other components and libraries so that it may operate like a Web Application Server.
Important note: The NodeJS is not the extended language of Javascript.

View more Tutorials:

Maybe you are interested

These are online courses outside the o7planning website that we introduced, which may include free or discounted courses.