An expression statement evaluates an expression and discards the result. It’s mainly useful for calling a resource function for its side effect.
There are no loops and no user-defined functions.
if statements
Anif statement runs its body only when its condition is true. The condition must be in parentheses and the body in curly braces.
else if branches to test more conditions in order, and an else branch to run when no condition matched:
- The condition must evaluate to a
boolean.if (1)orif (name)is an error: writeif (name != null)instead. - Curly braces are always required, even for a single statement.
- Each body is its own scope.
return
return ends the script immediately. Its value becomes the returnValue of the response, and any statements after it are skipped.
null if it uses a bare return or reaches the end of its body without a return.