Overview
There is a special object in JavaScript called a global object, and all of its properties can be accessed anywhere in the program, that is, global variables. In browser JavaScript, the window is usually a global object, while the global object in node. JS is global, and all global variables (except the global itself) are properties of the global object.
Api
varGVar = "Debug Project"; Global.projectname=GVar;/** * Nodejs global Variables*/functionTestglobalvar () {console.log (global.projectname); Console.log (__dirname); //Current PathConsole.log (__filename);//The path of the JS file currently executing //var t = setTimeout (CB, MS) //the SetTimeout (CB, MS) global function executes the specified function (CB) After the specified number of milliseconds (ms). : SetTimeout () executes the specified function only once. //cleartimeout (t) //the Cleartimeout (t) global function is used to stop a timer that was previously created by SetTimeout (). The parameter T is a timer created by the SetTimeout () function. //setinterval (CB, MS) //the SetInterval (CB, MS) global function executes the specified function (CB) After the specified number of milliseconds (ms). //returns a handle value representing the timer. You can use the Clearinterval (t) function to clear the timer. //the SetInterval () method keeps calling functions until Clearinterval () is called or the window is closed. //Console //Console is used to provide console standard output, which is a debugging tool provided by the JScript engine of Internet Explorer, and later becomes a de facto standard for browsers. //node. JS uses this standard to provide a console object that is consistent with customary behavior to output characters to the standard output stream (STDOUT) or standard error stream (stderr). //Process //process is a global variable, which is a property of the global object. //It is used to describe the object of the current node. JS process State and provides a simple interface to the operating system. Usually when you write a local command-line program, you have to deal with it. }
Reference:
node. JS Global Object
Global variables in Nodejs
NODEJS global variable-global