Skip to content

Instantly share code, notes, and snippets.

@bingo347
Created March 19, 2020 13:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bingo347/0ea968f4a89781ffcf0f26d25d5c8466 to your computer and use it in GitHub Desktop.
Save bingo347/0ea968f4a89781ffcf0f26d25d5c8466 to your computer and use it in GitHub Desktop.
globalThis simple polyfil
(() => {
const isNotUndefined = typeofResult => typeofResult !== 'undefined';
if(isNotUndefined(typeof globalThis) && globalThis.globalThis === globalThis) { return; }
const g = (isNotUndefined(typeof window) && window)
|| (isNotUndefined(typeof global) && global)
|| (isNotUndefined(typeof self) && self)
|| Function('return this')();
g.globalThis = g;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment