Preamble: I did a technical sharing about Node.js in the group last week, the content is easy to understand and simple. The general response is good, so I’m sharing it on the nuggets platform in the hope that more people who need to know node.js can see it
1. What is Node.js?
Basic concept: Javascript runtime environment based on Chrome V8 engine.
In other words: First of all, Node.js is not a development language or a back-end language. It is an environment, or platform, in which the javascript language can run directly.
2. How does Node.js work?
The Node.js platform can run javascript because of the V8 engine underlying it. Google Chrome runs front-end javascript and HTML files thanks to its powerful V8 engine. Node.js is a new platform based on chrome’s technology. Before Node.js, the javascript language was limited to browsers. With Node.js, the environment for javascript is expanded.
The schematic diagram is as follows:
3. Node.js features?
A. Asynchronous I/O: Read and write files asynchronously. You can read and write files asynchronously.
B. Single thread: The advantage is that there is no multi-thread deadlock like Java, and the single-core CPU can be used with high performance. The downside is that you can’t take advantage of multi-core cpus
C. Event-driven and callbacks
D. Cross-platform: Windows and Linux
4. Node.js Usage Scenarios?
In fact, as a front-end developer, you already use Node.js unconsciously. For example, the execution of scaffolding instructions of the front-end framework must rely on node.js environment, such as WebPack packaging tool, NPM package management (via NPM install package), and writing back-end programs (Express framework).
5. How to build a complete Web project with Node.js?
With node.js built, a complete Web project can be constructed by using the front-end framework +mongodb database + Express framework. All you need to do is know the javascript language. All you need is familiarity with the framework.
6. Compared to Java
It’s a mistake to compare Node.js to Java because they’re not on the same level. Node.js is the platform and Java is the language. If you have to compare, Node.js can compare to the JVM, and javascript can compare to the Java language. The former is just the running environment for the latter language.
Next time: Explore git