Last active
December 28, 2015 19:09
-
-
Save ghoullier/7548388 to your computer and use it in GitHub Desktop.
List non-inherited global variables
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
;(function (root, doc) { | |
'use strict' | |
var element = doc.documentElement | |
, iframe = doc.createElement('iframe') | |
, globals = Object.keys(root) | |
// Append iframe to the DOM | |
element.appendChild(iframe) | |
// Get inherited global variables | |
var inherited = Object.keys(iframe.contentWindow) | |
// Detach iframe | |
element.removeChild(iframe) | |
// Return non-inherited global variables | |
return globals.filter(function(value){return inherited.indexOf(value) < 0}) | |
}(this, this.document)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment