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


    for (variable of iterable) {


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:

    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

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

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

    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 loops.

COVID-19 NOTICE – Business as Usual
Evance continues to provide all services and support throughout this difficult period. See our full statement here .