globalThis
globalThis is the standardized name for the global object in JavaScript. It was introduced in ECMAScript 2020 to provide a single, environment-agnostic reference to the global scope across different execution environments, including browsers, Node.js, and web workers. In a browser, globalThis refers to the window object; in Node.js it refers to the global object; in web workers it refers to self. Accessing globalThis yields the same object regardless of where the code runs, enabling code that needs to reach global properties without environment checks.
You can read from or assign to global properties via globalThis, for example: globalThis.myGlobal = 42; console.log(globalThis.myGlobal);
Historically, code often checked for window, global, or self to access the global object, which led to