开发者

what mean .length property in an array variable

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜