Last active
August 29, 2015 14:15
-
-
Save daytonn/58b3b16151ed175d90ea to your computer and use it in GitHub Desktop.
CWCPOOJS - leaking globals
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
| var foo = 5; | |
| var bar = 10; | |
| function logFoo() { | |
| foo = 15; | |
| var bar = 20; | |
| console.log("logFoo scope") | |
| console.log(foo, bar); | |
| } | |
| logFoo(); // 15, 20 | |
| console.log("global scope (window)") | |
| console.log(foo, bar); // 15, 10 | |
| console.log(window.foo, window.bar); // 15, 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment