Last active
October 9, 2016 10:33
-
-
Save exah/2eb9bcca6c89984d40b819355f0e00c1 to your computer and use it in GitHub Desktop.
Log global variables
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
// Based on https://davidwalsh.name/global-variables-javascript | |
(function logGlobals() { | |
var iframe = document.createElement('iframe'); | |
iframe.onload = function() { | |
var iframeKeys = Object.keys(iframe.contentWindow); | |
var windowKeys = Object.keys(window); | |
windowKeys.forEach(function(key) { | |
if (iframeKeys.indexOf(key) === -1) { | |
console.log(key); | |
} | |
}); | |
}; | |
iframe.src = 'about:blank'; | |
document.body.appendChild(iframe); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment