Hello,
I am learning JavaScript and was using w3schools (I know w3fools) as a primer before jumping into videos, books, and other resources. Well everything was going quite well under I got to the [COLOR=“Green”]For…In[/COLOR] Statement.
Here is the definition:
The for…in statement loops through the elements of an array or through the properties of an object.
and there example:
<script type="text/javascript">
var x;
var mycars = new Array();
mycars[0] = "Saab";
mycars[1] = "Volvo";
mycars[2] = "BMW";
for (x in mycars)
{
document.write(mycars[x] + "<br />");
}
</script>
This is a bit confusing to me. I have not learned about arrays yet. I understand the var x but start getting confused when it gets to var mycars = new Array();
Does var x get redeclared as var mycars?
I kind of understand what is going on but I am not really confident. If someone could expain what is going on that would rock.
Thanks,
omgjtt :toad: