Previous Topic: The for Loop StatementNext Topic: The break Statement


The for/in Loop Statement

The for/in loop performs a sequence of statements for all values of a specified variable in a specified object. The for/in loop has the following syntax:

for (variable in object)
statement

The variable value is one of the following items:

In other words, the variable value is equivalent to the left side of an assignment expression. The object value is the name of an object or an expression that evaluates to an object.

For example, to loop through elements of an indexed field in a dataset, define an index variable and specify the indexed field as the object.

for (var i in Process.square)
Process.square[i] = i * i