Last active
December 21, 2015 21:09
-
-
Save afc163/6366114 to your computer and use it in GitHub Desktop.
Find the new global variable.
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() { | |
// save global scope | |
var scope = []; | |
for(var p in window) { | |
scope.push(p); | |
} | |
// code | |
window.a = 1; | |
// check global scope | |
// find the new global variable | |
for(var property in window) { | |
if (scope.indexOf(property) === -1) { | |
console.log('Found ' + property); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment