Last active
June 2, 2016 16:16
-
-
Save michaelficarra/791f9742ca95318278a63f82c536e564 to your computer and use it in GitHub Desktop.
get the global object as reliably as possible
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
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