Subquery Expressions
A subquery is a query block wrapped in parentheses and used as a value. Most often it is a FOR loop whose result — always an array — is assigned, returned, or passed to another expression.
The parentheses are required. A FOR loop written without them is the output of the query itself, not a value you can place inside another expression.
Composing transformations
Because a subquery is just a value, it can be used anywhere a value is expected — including as an argument to a function.
A subquery can also be indexed like any other array.
Nesting
The RETURN of one loop can be another subquery, which produces nested arrays.
Each inner subquery is evaluated once per iteration of the outer loop.
Subqueries and query expressions
A subquery composes FQL transformations: it runs a FOR block and hands you the result. This is different from a Query Expression, which delegates a query to a host value such as an HTML document. They share the word “query” but solve different problems — use a subquery to shape data with FQL, and QUERY to extract data through a host capability.