Array examples Last updated: 26. Jan 2023

Getting length of an array

#var myarray = split("1,4,5,6,7,8", ",")#

Array item count: #myarray.Length#

Looping an array

Alternativ not HTML attribute:

#for(var item of myarray) {#
    The array item is: #item#
#}#

Looping with objects

#for(var item of myarray) {#
    The array item is: #item.Field1# is the same as #item.Field1#
#}#

Same applies when using the data-loop attribute.

How to create an array of items

/* ... some code ... */

var items = [];
for(var item of otherArray) {
    /* ... some code ... */

    items.push({
        "Product" : productname,
        "Url" : url,
        "Price" : itemprice,
        "Length" : length
    }); /* adds an item to the array */
}