Today I ran into a problem that had me completely baffled.
A function that I have just written, processes data in any one of 4
different data grids.
Within a for() loop I need to call another specific function depending
on the grid being accessed. To do this I construct the function name
from a variable and a literal string. No problem yet.
When I ran the web page that called the function, the for() loop kept
going into what appeared to be an infinite loop(?), but I wasn't
updating the counter variable - or so I thought.
Eventually, it dawned on me what was happening. The called funtions
also have a for() loop using the same counter variable (both "i").
While neither function should be aware of the other's variable as they
were both locally declared and therefore should have been out of
scope, the called function was updating the calling function's counter
variable.
This seems weird in the extreme, but it was happening with both
FireFox and Internet Explorer, so it seem to be a javascript "thing".
The problem disappeared of course after I changed the calling
function's counter variable.
Something to be aware of, folks!