Array examples Last updated: 27. Aug 2024
Getting length of an array
#let myarray = docly.split("1,4,5,6,7,8", ",")#
Array item count: #myarray.length#
Looping an array
Alternativ not HTML attribute:
#for(let 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 ... */
let items = [];
for(let item of otherArray) {
/* ... some code ... */
items.push({
"Product" : productname,
"Url" : url,
"Price" : itemprice,
"Length" : length
}); /* adds an item to the array */
}