Last active
March 21, 2021 04:48
-
-
Save Goku-kun/6897d81ada45692dd11aefa67434b55b to your computer and use it in GitHub Desktop.
This is a reliable cross environment global object reference polyfill which allows access to the global object of any JS environment using the identifier called theGlobalScopeObject.
This file contains 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 theGlobalScopeObject = | |
(typeof globalThis != "undefined") ? globalThis : | |
(typeof global != "undefined") ? global : | |
(typeof window != "undefined") ? window : | |
(typeof self != "undefined") ? self : | |
(new Function("return this"))(); | |
// globalThis is a standardized object as of ES2020 which can be used to access the global scope. | |
// To find the reference of the global of any environment, the following script can be used: | |
var globalObject = (new Function("return this"))(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment