Skip to content

Instantly share code, notes, and snippets.

@ghoullier
Last active December 28, 2015 19:09
Show Gist options
  • Save ghoullier/7548388 to your computer and use it in GitHub Desktop.
Save ghoullier/7548388 to your computer and use it in GitHub Desktop.
List non-inherited global variables
;(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