Can be used to iterate over fields in a data set or rows in detail table. Also see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...in.
variable
object
Iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed.
This script iterates over field names in the current record and adds them to a paragraph.
for(var i in record.fields){ results.after("<p>" + i + "</p>"); }
This script iterates over fields in the current record, retrieving their values. Then it adds the values to a paragraph.
for(var i in record.fields){ results.after("<p>" + record.fields[i] + "</p>"); }