Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
Last active June 2, 2016 16:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelficarra/791f9742ca95318278a63f82c536e564 to your computer and use it in GitHub Desktop.
Save michaelficarra/791f9742ca95318278a63f82c536e564 to your computer and use it in GitHub Desktop.
get the global object as reliably as possible
var getGlobal = (function(g) {
if (g == null) {
if (typeof System !== 'undefined' && System != null && System.global != null && System.global.System === System) g = System.global;
else if (typeof self !== 'undefined' && self != null && self.self === self) g = self;
else if (typeof window !== 'undefined' && window != null && window.window === window) g = window;
else if (typeof global !== 'undefined' && global != null && global.global === global) g = global;
}
return function() { return g; };
}(this));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment