Yes it's global but it doesn't always work out that way.
I usually prefer not to do this - it's not so hard to initialize j
outside of the loop (and should not be a performance hit either). The
main reason is that in case this ever comes into question (if
specification of JS changes to make variables properly scoped), I won't
have to change my code at all :)
HTH,
Konstantin
Eric H. Jung wrote:
Hi,
I know this works in JS:
for (var i=0,j="foo";i<5; i++) {dump(i);}
dump(j);
It breaks typical scoping rules, but is there anything problematic with
it? Is everything "global" so it doesn't matter if I do this?
thanks,
eric
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners