The numbers in an arithmetic operation are called operands.
The operation to be performed between the two operands is defined by an operator.
| Operand | Operator | Operand |
|---|---|---|
| 50 | + | 60 |
The assignment operator (=) assigns a value to a variable.
var x = 10;
The addition operator (+) adds numbers:
var x = 5;
var y = 6;
var z = x + y;
The addition operator (*) multiplies numbers:
var x = 5;
var y = 6;
var z = x * y;
Arithmetic operators are used to perform arithmetic operations on numbers.
| Operator | Description |
|---|---|
| + | Addition |
| - | Subtraction |
| * | Multiplication |
| / | Float division |
| div | Integer division |
| Operator | Description |
|---|---|
| == | Equal to |
| != | Not equal |
| > | Greater than |
| < | Less than |
| >= | Greater than or equal to |
| <= | Less than or equal to |
| Operator | Description |
|---|---|
| && | Logical and |
| || | Logical or |
| ! | Logical not |
Next, we will explore conditionals, which make use of comparison operators.