Skip to content

Instantly share code, notes, and snippets.

@Richienb
Created March 13, 2020 11:12
Show Gist options
  • Save Richienb/fc441d160fb010a65c755cba3e6e6c14 to your computer and use it in GitHub Desktop.
Save Richienb/fc441d160fb010a65c755cba3e6e6c14 to your computer and use it in GitHub Desktop.
globalThis ponyfill.
function getGlobalThis() {
if (typeof globalThis === 'object') return globalThis;
Object.defineProperty(Object.prototype, '__magic__', {
get: function() {
return this;
},
configurable: true
});
const globalThis_ = __magic__;
delete Object.prototype.__magic__;
return globalThis_
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment