function simpleForLoopToShowVarBehavior() { for(var i = 0; i < 10; i++) { console.log(i); // You may think that i is scoped only inside this for loop } console.log(i); // Voila, for some magical reason you see '10' as output of this line // which means Javascript Var is not the variable declaration that you dreamt of // The i variable gets the value '10' from the last iteration of the for loop }