Javascript/Node.js
[Node.js] global
Rainbow🌈Coder
2022. 5. 14. 01:31
728x90
Global objects | Node.js v16.15.0 Documentation (nodejs.org)
Global objects | Node.js v16.15.0 Documentation
Global objects# These objects are available in all modules. The following variables may appear to be global but are not. They exist only in the scope of modules, see the module system documentation: The objects listed here are specific to Node.js. There ar
nodejs.org
console.log(global);
브라우저에서는 window가 글로벌 객체이고,
node.js에서는 global 이 글로벌 객체이다.
C:\Users\User\gitprogect\NodeJs> node 1-global/app
<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: 82.2766999900341,
nodeStart: 1.1915000081062317,
v8Start: 4.617000013589859,
bootstrapComplete: 58.125800013542175,
environment: 25.251300007104874,
loopStart: -1,
loopExit: -1,
idleTime: 0
},
timeOrigin: 1652455410843.36
},
clearImmediate: [Function: clearImmediate],
setImmediate: [Function: setImmediate] {
[Symbol(nodejs.util.promisify.custom)]: [Getter]
}
}
global.hello = () => {
console.log("hello");
};
global.hello(); //hello
hello(); //hello
global.hello = () => {
global.console.log("hello");
};
global.hello(); //hello
hello(); //hello728x90