1. Five methods for global Object console: Log dir time timeend error
2. The Consle object is defined in the Global Object window in the front-end
3. In Nodejs, the global object is globally and the console is defined in global.
4. SetInterval is also a global object defined in global
5. SetTimeout is also a global object defined in global
6. __dirname is also a global object that represents the path where the current file resides
7. __filename is also a global object that represents the path where the current file is located (plus the name of the file)
8. Exports is the exposure require is quoted
9. Module exposure Moudle has a property of exports
Small summary: Global objects in node: Console setinteval setTimeout __dirname __filename require exports module
Small summary: What is exposed in node: variables, objects, functions, constructors, factory methods
Exposure with the Module property allows you to add properties without adding attributes
If the module adds a property, the content of the exposure is the same as the exports exposure
1 Exposure variables
Exports.a=a
Module.exports=a
2 Exposure Object
Var A={a:1}
Module.exports=a
3 Exposure function
Function foo () {
Console. Log (' Hello ')
}
Module.exports=foo
4 Exposure constructor
5 Exposure Factory method
What is a factory method
(1 ) using the new object Creating Objects
(2 ) Use return in the function return This object
The factory method does not need to use new object is created
Because the factory method was exposed in the b.js, the obj here is the factory method
Calling this factory method will put back an object
1 Reference exposure function
Console.log (obj)
2 Reference exposure function
Because a function is stored, obj is the function that exposes it.
3 constructors that reference exposure
Because B.js is a construction method, this is where obj is a construction method
Nodejs Global Objects