Global Scope

Bad practices that mess with global scope.

by EisenbergEffect

HTML

<script src="https://getfirebug.com/firebug-lite-debug.js"></script>

JavaScript

//Always use var...or else...
test = "This is a test";

console.log(test);
console.log(window.test);

var myBadFunc = function(){
    test = "I just munged test...";
    another = "I inadvertantly created another global";
}
    
myBadFunc();

console.log(test);
console.log(window.another);