J
Jack
Hi,
Is it recommended to use the var keyword when declaring a variable?
IE lets me create a variable with var, then create the same one again
with no problem.
Also it lets me create a variable without the var keyword. As such the
code below works fine:
<html>
<script>
test = 1;
var test2 = 2;
var test = 3;
var test2 = 4;
alert(test);
alert(test2);
</script>
</html>
Also, is there a good reason not to do for statements like:
for (li=0;li<10;li++){;}
instead of:
for (var li=0;li<10;li++){;}
Cheers,
Is it recommended to use the var keyword when declaring a variable?
IE lets me create a variable with var, then create the same one again
with no problem.
Also it lets me create a variable without the var keyword. As such the
code below works fine:
<html>
<script>
test = 1;
var test2 = 2;
var test = 3;
var test2 = 4;
alert(test);
alert(test2);
</script>
</html>
Also, is there a good reason not to do for statements like:
for (li=0;li<10;li++){;}
instead of:
for (var li=0;li<10;li++){;}
Cheers,