Table of Contents

5.9 The Grouping Operator

Aside from being used in function calls, parentheses—( )—can also be used to group a phrase of code to override the precedence of various operators. (They also enhance legibility, even if they are not required to override the default precedence.) Parentheses are also required in some statements, most notably if statements. Parentheses take the general form:

(expression)

The expression within the parentheses is evaluated and returned. Here are some examples:

if (x =  = y) {                 // Syntactically required for if statement
  trace("x and y are equal"); // Required for the function call
}
(5 + 6) * 7                   // Force a nonstandard order of operation
(x >= 100) || (y <= 50)       // Parentheses not required but added for legibility
x >= 100 || y <= 50           // No parentheses...a little harder to read

Table of Contents