Description

This eases yet another JavaScript pita. Replaces the different global object names:

  • window (browser)
  • global (node)
  • self (web workers)

with globalThis.

Syntax

if (typeof globalThis.alert === "function") {
  globalThis.alert("hi");
}