coderef

globalThisBaseline · Widely available

The globalThis property accesses the global this value (and hence the global object itself) across environments.

Supported in all major browsers for at least 30 months — safe to use without fallbacks. Baseline since Jan 15, 2020. Widely available since Jul 15, 2022.

Browser support

DesktopChrome
1–70Not supported
71+Supportedsince Dec 4, 2018
Current: 155
Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154
Firefox
1–64Not supported
65+Supportedsince Jan 29, 2019
Current: 157
Safari
1–12Not supported
12.1+Supportedsince Mar 25, 2019
Current: 27
MobileChrome Android
18–70Not supported
71+Supportedsince Dec 4, 2018
Current: 155
Firefox Android
4–64Not supported
65+Supportedsince Jan 29, 2019
Current: 157
Safari iOS
1–12Not supported
12.2+Supportedsince Mar 25, 2019
Current: 27

How to use

This feature is Baseline widely available — use it freely, no fallback needed.

Example

Full syntax and examples are on MDN: globalThis.

Feature detection

JS · check before using
if (typeof globalThis !== "undefined") {
  // globalThis is available
}

Documentation (MDN)

Specification