JavaScript Array: In this tutorial you will come to know about array in JavaScript, how to declare, assign values, access values using simple for loop as well as using for..in loop.
JavaScript Array: In this tutorial you will come to know about array in JavaScript, how to declare, assign values, access values using simple for loop as well as using for..in loop.<html>
<head>
<title>Write your title here </title>
<script type="text/javascript" >
var x;
var str=new Array();
str[0]="This";
str[1]=1;
str[2]=true;
str[3]=323.233;
document.write("<b>Using simple for loop</b> <br/>");
for(i=0;i<str.length;i++)
{
document.write(str[i]+"<br/>");
}
document.write("<b>Using for...in or for each loop</b> <br/>");
for(x in str)
{
document.write(str[x]+"<br/>");
}
</script>
</head>
</html>
Output:
Using simple for loop This 1 true 323.233 Using for...in or for each loop This 1 true 323.233