what is for....in statement in javascript

Posted by dramasea on Stack Overflow See other posts from Stack Overflow or by dramasea
Published on 2010-12-30T02:12:34Z Indexed on 2010/12/30 2:54 UTC
Read the original article Hit count: 306

Filed under:
|

anyone can explain how to use for...in statement in javascript. I had read the w3school article but i think it is not so clear.Below is the code, please explain this:

<html>
<body>
<script type="text/javascript">
var x;
var mycars = new Array();
mycars[10] = "Saab";
mycars[20] = "Volvo";
mycars[30] = "BMW";

for (x in mycars)
{
document.write(mycars[x] + "<br />");
}
</script>
</body>
</html>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about for-in