The Javascript for...in statement is a loop mechanism that will iterate over all of the items in an array, and execute code for each item.
You establish two parameters inside of its parenthesis:
- Create the variable that represents each item as they pass through the loop.
- Specify the array to access.
Javascript CODE EXAMPLE
var peopleArray = new Array("Bill","Jane","Fred","Sara");
for (var person in peopleArray) {
document.write(peopleArray[person] + " is in the array<br />");
}
Related Material
· Javascript loops
· break
· continue