global / globalThis
The global object in Node.js; globalThis is the portable standard alias.
Syntax
globalThis / global Returns
object — The global namespace object.
Examples
globalThis.APP_VERSION = '1.0.0';
console.log(APP_VERSION);
Output
1.0.0
console.log(typeof globalThis.fetch);
console.log(global === globalThis);
Output
function
true
Notes
Prefer `globalThis`: it works identically in browsers, workers, and
Node, whereas `global` is Node-specific. Polluting the global scope
is discouraged; pass dependencies explicitly instead. Module-scope
variables are NOT global in Node.