Last active
April 23, 2019 17:27
-
-
Save shisama/52194cb11d9caf1177851db12c012849 to your computer and use it in GitHub Desktop.
globalThis - New JavaScript Features in Node.js v12
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 getGlobal = () => { | |
if (typeof self !== 'undefined') { return self; } | |
if (typeof window !== 'undefined') { return window; } | |
if (typeof global !== 'undefined') { return global; } | |
throw new Error('unable to locate global object'); | |
}; | |
const globals = getGlobal(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment