NODEJS global variable-global

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.