Can I ask what mean .length property in the array variable? I look through many article and many of them stated that .length return the number of string. So can anyone give me an answer? Below is the code:
<script type="text/javascript">
var mycars = new Array();
mycars[0] = "Saab";
mycars[1] = "Volvo";
mycars[2] = "BMW";
for (i=0;i<mycars.length;i++)
{
document.write(mycars[i] + "<br />");
}
</script开发者_C百科>
.length
returns the number of elements in the array. That's how many items you need to iterate over in your for
loop when looking at all of them.
精彩评论