What is node?
Node is a running environment for js to run on the server side. Its bottom layer is written in C++ with high performance. There are also many new system-level apis based on ECMAScript, such as file manipulation, network programming (implementing your own Web services).
What problem does Node solve?
1, with the characteristics of JS single thread, to solve the problem of high concurrency server
2, write some tool libraries, such as build tools Webpack, scaffolding CLI
3. Build an intermediate layer to solve cross-domain problems and data formatting operations
Node is suitable for Web application scenarios (IO intensive), such as returning files and reading and writing files
Core features of Node
Event-driven. Node’s API is event-based and asynchronous
Node uses a single thread
3, Node is not suitable for CPU intensive, suitable for IO intensive
Synchronous asynchronous block non-blocking (for different points)
-
Synchronous and asynchronous focus on the message notification mechanism readFile
-
The state in which blocking and non-blocking programs wait for message results
VIP exclusive customer service is synchronous, public customer service is asynchronous
The global object in Node is global
- Global objects are directly accessible variables,
- If a property is defined on global, it must be a global variable