开发者

what mean .length property in an array variable

开发者 https://www.devze.com 2023-02-02 10:24 出处:网络
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?

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

精彩评论

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