This question already has an answer here:
This took me a while to track it down, and I can fix it by changing:
for(i = 1; i < 2; i++)
to
for(var i = 1; i < 2; i++)
But why is it in scope at all in the first example, it must be by design.
loop();
function whyIsIinScope()
{
alert('why is i in scope? i is ' + i );
}
function loop()
{
for(i =1; i < 2; i++)
{
whyIsIinScope();
}
}
Aucun commentaire:
Enregistrer un commentaire