for...of

The for...of statement creates a loop iterating over iterable objects (including Array and Collection objects).

Syntax

<?ev
    for (variable of iterable) {
        statement
    }
?>

Where...

variable On each iteration a value of a different property is assigned to variable.
iterable Object whose enumerable properties are iterated.


Try it out

Let's say you want to iterate through a page's children:

<?ev
    for(var childpage of page.children){
        echo(childpage.title.wrap('<h3 />'));
    }
?>

The code above iterates through page.children, which in this case is a collection of pages. Each sub-page is then assigned to childpage.

Difference between for...of and for...in

In EVML the for...in statement is designed to iterate across an objects properties rather than the values within the properties.

The following example highlights the difference between for...in and for...of

<?ev
    var myArray = ['One', 'Two', 'Three'];
    
    for(var i of myArray){
        print(i); // One, Two, Three
    }
    
    for(var i in myArray){
        print(i); // 0, 1, 2
    }
?>

See also for...in loops.