for each…in loops
These loops are part of the E4X standard. Unlike other for loop constructs, for each…in loops usually have no explicit counter; they essentially say "do this to everything in this set" rather than "do this X times." This avoids possible off-by-one errors and makes code easier to read. These loops are used to iterate through elements in an array (or collection) or in the property values of an object.
Syntax (for each...in loops) | Example |
---|---|
|
|