Global ObjectAll modules can be called
Global FunctionsTimer functions: There are 4 timer functions: setTimeout(), clearTimeout(), setInterval(), clearInterval(). require: used to load modules. It was often seen in King Qi's house and heard several times in Cui Jiu's hall. Global variables
Quasi-global variablesThe local variables inside the module point to different objects depending on the module, but they are applicable to all modules and can be regarded as pseudo-global variables, mainly module, module.exports, exports, etc. The module variable refers to the current module. The module.exports variable represents the interface exported by the current module. When other files load the module, they actually read the module.exports variable.
Global sample code // Include the full path of the file name console.log(__filename); // The path to the file (excluding the file name) console.log(__dirname); // Timing function, usage is similar to the timing function in the browser var timer = setTimeout(function(){ console.log(123); },1000); setTimeout(function(){ clearTimeout(timer); },2000); // There is no window object in Node.js, but there is a similar object global, which can be omitted when accessing global members global.console.log(123456); // argv is an array. By default, the first two items are: the path of the Node.js environment; the full path of the currently executed js file // Starting from the third parameter, it represents the command line parameters console.log(process.argv); // Print the current system architecture (64-bit or 32-bit) console.log(process.arch); This is the end of this article about the specific use of node.js global variables. For more relevant node.js global variables content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: How to quickly delete all tables in MySQL without deleting the database
The following example code introduces the princip...
This article example shares the specific code of ...
Preface In general development, images are upload...
FTP and SFTP are widely used as file transfer pro...
Table of contents 1. Basic SELECT statement 1. Qu...
Preface: In Vue, props can be used to connect ori...
Online Preview https://jsrun.pro/AafKp/ First loo...
Table of contents 1. Download MySQL 2. Install My...
Table of contents Require Implementation Code dat...
There are many form elements. Here is a brief sum...
Preface Excel is powerful and widely used. With t...
1. What are the templates for ASP.NET Web applicat...
Table of contents Preface Can typeof correctly de...
This article shares the specific code for js to r...
1. Use contrasting colours. The contrast here ref...