How JavaScript iterates through every element in an array

Source: Internet
Author: User

How JavaScript iterates through each element in the array:
Iterating through all the elements in an array is a very basic and simple operation, perhaps not enough for beginners to understand, and here's a code example to show you how to implement this functionality.
The code is as follows:

var thearray=["Ant Tribe", "Qingdao South District", "New Sharp Technology", 3];  for (var index=0;index<thearray.length;index++) {  console.log (Thearray[index]);}

The code above can iterate through each element in the array, and the principle is simple, which is to implement this function with a for loop and array index.
Related reading:
The 1.for loop can be found in the section on the use of JavaScript for loop statements .
The 2.length property can be found in the section of the length property of the JavaScript array object .

The original address is http://www.softwhy.com/forum.php?mod=viewthread&tid=11730

For more information, refer to: http://www.softwhy.com/javascript/

How JavaScript iterates through every element in an array

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.