1、global :全局变量的宿主(类似于浏览器js中的window对象),这是一个特殊的对象,称为全局对象(Global Object),它及其所有属性都可以在程序的任何地方访问
// window.console.log('hello')
//全局变量
console.log(global) //等价于window
console.log(__dirname) //当前目录 D:\2022-03-07\01nodejs\day01\下午\code
console.log(__filename) //当前目录 + 文件 D:\2022-03-07\01nodejs\day01\下午\code\01demo.js
<ref *1> Object [global] {
global: [Circular *1],
clearInterval: [Function: clearInterval],
clearTimeout: [Function: clearTimeout],
setInterval: [Function: setInterval],
setTimeout: [Function: setTimeout] {
[Symbol(nodejs.util.promisify.custom)]: [Getter]
},
queueMicrotask: [Function: queueMicrotask],
performance: Performance {
nodeTiming: PerformanceNodeTiming {
name: 'node',
entryType: 'node',
startTime: 0,
duration: 63.29450000077486,
nodeStart: 0.8341000005602837,
v8Start: 3.122699998319149,
bootstrapComplete: 42.31549999862909,
environment: 21.217199999839067,
loopStart: -1,
loopExit: -1,
idleTime: 0
},
timeOrigin: 1646642687631.532
},
clearImmediate: [Function: clearImmediate],
setImmediate: [Function: setImmediate] {
[Symbol(nodejs.util.promisify.custom)]: [Getter]
}
}