Skip to content

Instantly share code, notes, and snippets.

@rdillmanCN
Created December 30, 2017 09:21
Show Gist options
  • Save rdillmanCN/a7c4d8528d5481108f88ae81242fffb0 to your computer and use it in GitHub Desktop.
Save rdillmanCN/a7c4d8528d5481108f88ae81242fffb0 to your computer and use it in GitHub Desktop.
Find all globals not native to the window object.
(function f() {
var frm = document.createElement("iframe");
frm.style.display = "none";
document.body.appendChild(frm);
var a = Object.getOwnPropertyNames(frm.contentWindow);
var b = Object.getOwnPropertyNames(window);
var tab = {};
b.filter(function(c) {
return a.indexOf(c) === -1;
}).map(function(i) {
if (typeof window[i] !== 'undefined') {
tab[i] = Array.isArray(window[i]) ? 'array' : typeof window[i];
}
});
document.body.removeChild(frm);
console.group("Globals Data");
console.table(tab);
console.groupEnd("Globals Data");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment