Created
March 19, 2020 13:23
-
-
Save bingo347/0ea968f4a89781ffcf0f26d25d5c8466 to your computer and use it in GitHub Desktop.
globalThis simple polyfil
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
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