Mike Austin's Blog

Saturday, January 05, 2008

Don't forget your "var" in JavaScript for loops

for (i = 0; i < nodes.length; i++)
"i" is now a global variable, and mixed with recursion... well, it's not good.

It should be:
for (var i = 0; i < nodes.length; i++)

0 Comments:

Post a Comment

<< Home