Skip to content

Instantly share code, notes, and snippets.

@exah
Last active October 9, 2016 10:33
Show Gist options
  • Save exah/2eb9bcca6c89984d40b819355f0e00c1 to your computer and use it in GitHub Desktop.
Save exah/2eb9bcca6c89984d40b819355f0e00c1 to your computer and use it in GitHub Desktop.
Log global variables
// 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