Array iterate

In this chapter you will learn:

  1. How to enumerate the Contents of an Array

Enumerating the Contents of an Array

You can enumerate the content of an array using a for loop.

<!DOCTYPE HTML><!-- j  av a  2s  .  c o m-->
<html>
<body>
  <script type="text/javascript">
    var myArray = [ 100, "Adam", true ];
    for ( var i = 0; i < myArray.length; i++) {
      document.writeln("Index " + i + ": " + myArray[i]);
    }
  </script>
</body>
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to access the number of elements in an array
  2. Array length is not read-only
Home » Javascript Tutorial » Array
Array Type
Array creation
Array type detecting
Array iterate
Array Length
Add to Array
Array join
Array concat()
Array every method
Array search from start with indexOf()
Array search from the end with lastIndexOf()
Array filter
Array mapping
Array forEach
Array pop and push
Array shift()
Array reduce()
Array reduceRight()
Array reverse()
Array slice()
Array some()
Array splice()
Array sort()
Array toString()
Array unshift()