Here is the code:
window.test1 = 'Jack';
setInterval(function(){
console.log(test1); // Works fine, expect output: "Jack"
}, 2000);
Refresh the window and enter:
window.test1 = 'Jack';
setInterval(function(){
var test1 = test1 || [];
console.log(test1); // Works bad, get [] instead of "Jack"
}, 2000);
Why is this happening?