globalThis, and the four ways it used to be written

A library that runs in a browser, in Node and in a worker had four different names for the global object and a small dance to pick one.

// the dance
const g = typeof globalThis !== 'undefined' ? globalThis
  : typeof window !== 'undefined' ? window
  : typeof self !== 'undefined' ? self
  : typeof global !== 'undefined' ? global : this;

// ES2020
globalThis.myLibrary = { version: '1.0' };

It matters almost exclusively for library authors and for polyfill code, which is where the dance appeared. Reaching for it in application code is usually a sign that something is being stashed globally that should be a module export. The name is deliberately awkward to discourage exactly that, which is a rare case of a committee choosing friction on purpose.