# Help with beginner JavaScript

**URL:** <https://forum.kirupa.com/t/help-with-beginner-javascript/318637>\
**Category:** web dev\
**Created:** [January 25, 2011, 10:25pm UTC](https://forum.kirupa.com/t/help-with-beginner-javascript/318637 "2011-01-25T22:25:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![omgjtt](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@omgjtt](https://forum.kirupa.com/u/omgjtt)\
**Post date:** [January 25, 2011, 10:25pm UTC](https://forum.kirupa.com/t/help-with-beginner-javascript/318637/1 "2011-01-25T22:25:27Z")

</div>

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:

```auto
<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:
