- node. JS Global Object
- Special objects in JavaScript: Global objects, Universal object
- It and all its properties can be accessed from anywhere in the program
- In browser JavaScript, typically window is a global object, and node. JS is global, and all global variables (except global itself) are properties of the global object
- ECMAScript definition, global variables include
- Variables defined at the outermost layer
- Properties of global objects
- Implicitly defined variables (no direct assignment defined)
- When defining a global variable, this variable becomes a property of the global object and vice versa
- It is not possible to define variables at the outermost layer in node. js because all user code belongs to the current module and the module itself is not at the outermost
- Note It is best to always use Var to define variables to avoid introducing global variables, which pollute namespaces and increase the risk of code coupling
- __filename
- Console.log (__filename);
- Output the file name of the currently executing script, output absolute path
- If the module file path is output in the module
- __dirname
- Console.log (__dirname);
- The directory where the output execution script resides
- SetTimeout (CB, MS)
- The global function, which executes the specified function CB after the specified number of milliseconds, executes only once
- Note that the program does not stop at this statement, but will continue
- Cleartimeout (t)
- Console
- Console is used to provide console standard output, which is a debugging tool provided by IE's JScript engine, and later becomes the de facto standard of the browser.
- node. JS uses this standard to stderr output characters to standard output stream stdout and standard error streams
- Console method
- Links: http://www.runoob.com/nodejs/nodejs-global-object.html
- Process
- Process is a global variable, that is, the properties of the global object
- An object that describes the state of the current node. JS process and provides a simple interface to communicate with the operating system
- Event: Exit/beforeexit/uncaughtexcepiton/signal
- Exit Status:
- Property: Stdout/stderr/stdin/argv/execpath/env/exitcode/version/pid/platform
- Method Reference Manual:
- Links: http://www.runoob.com/nodejs/nodejs-global-object.html
Node. JS Series notes 4-(not updated regularly)