Skip to content

Instantly share code, notes, and snippets.

@shisama
Last active April 23, 2019 17:27
Show Gist options
  • Save shisama/52194cb11d9caf1177851db12c012849 to your computer and use it in GitHub Desktop.
Save shisama/52194cb11d9caf1177851db12c012849 to your computer and use it in GitHub Desktop.
globalThis - New JavaScript Features in Node.js v12
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