The statement iterates over the enumerable properties of an object.


    for (variable in object) {


variable A different property name is assigned to variable on each iteration.
In Arrays or Collections this is usually the element index.
object Object whose enumerable properties are iterated.

Try it out

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

    for(var i in page.children){
        var childpage = page.children[i];
        echo(childpage.title.wrap('<h3 />'));

The code above iterates through page.children, which in this case is a collection of pages. The variable i is assigned the index property of the child page on each iteration. 

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

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