1. Composition of Node.js

  • JavaScript consists of three parts: ECMAScript, DOM, and BOM.
  • Node.js is made up of additional apis provided by ECMAScript and the Node environment, including files, networks, paths, and more powerful ones

2. Basic Syntax of Node.js

All ECMAScript syntax is available in the Node environment.

To execute the code in the Node environment, use the Node command to execute the.js file

3. Node.js Global object

In the browser the global object is window, in Node the global object is global.

Node has the following methods under global objects, which can be used anywhere. Global can be omitted.

  • Console.log () is printed in the console
  • SetTimeout () Sets the timeout timer
  • ClearTimeout () Clears the timeout timer
  • SetInterval () sets the interval timer
  • ClearInterval () Clears the intermittent timer