15. node global 객체 2
console.log(global);
// <ref *1> Object [global] {
// global: [Circular *1],
// queueMicrotask: [Function: queueMicrotask],
// clearImmediate: [Function: clearImmediate],
// setImmediate: [Function: setImmediate] {
// [Symbol(nodejs.util.promisify.custom)]: [Getter]
// },
// structuredClone: [Getter/Setter],
// clearInterval: [Function: clearInterval],
// clearTimeout: [Function: clearTimeout],
// setInterval: [Function: setInterval],
// setTimeout: [Function: setTimeout] {
// [Symbol(nodejs.util.promisify.custom)]: [Getter]
// },
// atob: [Getter/Setter],
// btoa: [Getter/Setter],
// performance: [Getter/Setter],
// fetch: [AsyncFunction: fetch],
// crypto: [Getter]
// }
// ------------------------------------------------------------------------
// node에선 global
// browser에선 window
// 헷갈리므로 globalThis로 통일됨
// -------------------------------------------------------------------------------------------
console.log(globalThis);
// <ref *1> Object [global] {
// global: [Circular *1],
// queueMicrotask: [Function: queueMicrotask],
// clearImmediate: [Function: clearImmediate],
// setImmediate: [Function: setImmediate] {
// [Symbol(nodejs.util.promisify.custom)]: [Getter]
// },
// structuredClone: [Getter/Setter],
// clearInterval: [Function: clearInterval],
// clearTimeout: [Function: clearTimeout],
// setInterval: [Function: setInterval],
// setTimeout: [Function: setTimeout] {
// [Symbol(nodejs.util.promisify.custom)]: [Getter]
// },
// atob: [Getter/Setter],
// btoa: [Getter/Setter],
// performance: [Getter/Setter],
// fetch: [AsyncFunction: fetch],
// crypto: [Getter]
// }
// -------------------------------------------------------------------------------------------
// globalThis <- 인터넷 익스플로러에선 안됨. 최신 브라우저에서만 지원 // 하지만 인터넷 익스플로러는 없어졌으므로 이젠 괜찮.
// -------------------------------------------------------------------------------------------
// node global, browser window 통일 -> globalThis
// 하지만 globalThis엔 window 처럼 document를 조작할 수 있는 속성들은 들어있지 않다. 브라우저가 아니기 때문.
// -------------------------------------------------------------------------------------------
// global.require
// global.setTimeout
// global.console.log
// window 생략하듯 위에서도 global 생략 가능하다.