opening round bracket
( and closing round bracket
Round brackets are used to group expressions when we need an order of operations that isn't the default order.
When we talk about order of operations (a concept from mathematics), in programming this exists in the form of operator precedence.
10 * x + 1 10 * (x + 1) (10 * x) + 1
You can recognize brackets that are used for grouping by the fact that they're always placed directly after an operator (like
+ in the above example).
If an opening bracket is placed directly after an expression instead, then it's a function call.
Function call expression
When an opening bracket directly follows an expression, it's the start of a function call expression.
The opening bracket in a function call expression is the middle of the expression, and it marks the two parts of a function call:
sendMessage("jon", "Meeting at noon"); //---left--^--------right------------
- On the left: the expression that provides the function to be called
- On the right: a list of expressions that provide the arguments to the function call
It's common enough to call a function and provde no arguments, which means that the opening bracket is followed by a closing bracket with nothing in between.