Understanding what Node.js is is so easy

Understanding what Node.js is is so easy

Official introduction to Node.js

On the homepage of the Node.js official website, there is a sentence describing Node.js:

Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.

Translated, it means:

Node.js is a JavaScript runtime based on Chrome's V8 JavaScript engine. Node.js adopts an event-driven, non-blocking I/O model, making it lightweight and efficient.

The first sentence of the above sentence explains what Node.js is, and the second sentence explains the characteristics of Node.js.

To understand the specific meaning of this official statement, we have to start with the JavaScript language.

The core development language of Node.js

It is assumed here that you have mastered the basic syntax and basic usage of the JavaScript language. If you haven't mastered JavaScript yet, you should first learn the JavaScript language.

Those who have mastered the JavaScript language should know that JavaScript is a scripting language for browsers that can enable interaction between web pages and users.

What is interaction? For example, when a user enters a username or password on a web page, this user input behavior can be called interaction. Or when a user clicks a button on a web page, etc., it can be called interaction.

The reason why JavaScript language can realize the interaction between web pages and users is mainly through events. For example, user input events, button click events, and so on.

Next, we take the behavior of a user clicking a button as an example to see how the JavaScript language handles it.

From the above analysis chart, we can clearly see:

  1. The user clicks a button on the web page to execute JavaScript logic.
  2. JavaScript logic goes through three stages: capturing events, triggering events, and event bubbling.
  3. When the JavaScript logic is executed, the result will be returned to the web page.
  4. The web page is then displayed to the user based on the results.

Through such a small case, we can know that JavaScript language handles the interaction between web pages and users, mainly relying on event-driven.

Differences between JavaScript on the web and in Node.js

Currently, almost all browsers support the JavaScript language. The reason for this is that the JavaScript engine is integrated into the browser.

Among many browsers, Chrome browser has relatively better performance, and the V8 JavaScript engine integrated in Chrome browser is open source.

Node.js uses the open source V8 JavaScript engine of the Chrome browser. So what is the difference between using JavaScript in a web page and using JavaScript in Node.js? We can understand this through the picture below.

It can be clearly seen from the above figure that Node.js does not provide WebKit kernel and HTML-related UI technologies compared to browsers. That is to say, Node.js only provides JavaScript language.

Why do you do this? In fact, the original idea of ​​the author of Node.js was to design a lightweight and efficient server.

What is a server

So what is a server? If a web application is compared to a person, then the server is the person's brain.

From the above figure, we can know that when people communicate with each other, they basically go through the following steps:

  1. When others communicate with me, I receive it through my human senses.
  2. The senses transmit information to the brain.
  3. After the brain receives the information, it processes it and returns the results.
  4. Then I give feedback to the person I am communicating with through my senses.

Through this process, we can find that others communicate with me directly through their senses, and do not know how the brain works, nor do they care about how the brain works.

WEB applications are similar to people. Users interact with web pages, which pass information to the server. The server receives, processes and responds, and finally the web page displays the results to the user.

As a user, you don’t care how the server works, and you may not even feel the existence of the server. However, as a developer, if you want to develop a complete WEB application, the logical core of the server.

From now on, we need to shift from user thinking to development thinking. Re-examine the WEB applications we have used before through development thinking, and you will find some differences.

A change in mindset is important! Very important! Very important! Important things should be said three times.

A simple understanding of Node.js

Having said that, we can briefly summarize what Node.js is.

Node.js is a server technology based on the V8 JavaScript engine of the Chrome browser, with JavaScript as the core development language.

What would it be like to develop a WEB application using Node.js?

Since JavaScript logic is event-driven, it is not difficult to understand that Node.js is event-driven.

If you want to better understand and master Node.js, you should first go back and brush up on the event handling in JavaScript language!

In addition to being based on the V8 engine of the Chrome browser, Node.js also provides a series of modules that allow us to easily implement some functions. For example, processing client requests, file processing and other operations.

When we learn Node.js, we mainly learn the module content provided by Node.js.

The above is the detailed content of how to understand what Node.js is. For more information about Node.js, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Usage of Node.js http module
  • Nodejs Exploration: In-depth understanding of the principle of single-threaded high concurrency
  • Specific use of node.js global variables
  • AsyncHooks asynchronous life cycle in Node8
  • Nodejs error handling process record
  • The whole process of node.js using express to automatically build the project
  • How to use shell scripts in node
  • The core process of nodejs processing tcp connection
  • Detailed explanation of Nodejs array queue and forEach application
  • Comparing Node.js and Deno

<<:  Nginx reverse proxy configuration removes prefix

>>:  Ubuntu MySQL version upgraded to 5.7

Recommend

Detailed explanation of the use of Vue.js draggable text box component

Table of contents Registering Components Adding C...

Understand the initial use of redux in react in one article

Redux is a data state management plug-in. When us...

Next.js Getting Started Tutorial

Table of contents Introduction Create a Next.js p...

Steps to split and compress CSS with webpack and import it with link

Let's take a look at the code file structure ...

Analysis of GTK treeview principle and usage

The GtkTreeView component is an advanced componen...

How to convert Chinese into UTF-8 in HTML

In HTML, the Chinese phrase “學好好學” can be express...

JavaScript to achieve the effect of tab bar switching

Tab bar: Click different tabs to display differen...

Summary of MySQL basic common commands

Table of contents MySQL basic common commands 1. ...

Summary of commonly used SQL in MySQL operation tables

1. View the types of fields in the table describe...

The connection between JavaScript constructors and prototypes

Table of contents 1. Constructors and prototypes ...

Summary of considerations for writing web front-end code

1. It is best to add a sentence like this before t...

Detailed explanation of Javascript closures and applications

Table of contents Preface 1. What is a closure? 1...

How to use LibreOffice to convert document formats under CentOS

Project requirements require some preprocessing o...

MySQL json format data query operation

The default table name is base_data and the json ...