**Operators** allow you to assign values to variables, compare values, and define conditional statements. Arcade supports the following operators.

## Arithmetic operators

Arithmetic operators are used to perform arithmetic on numbers. See Type casting - Arithmetic statements to learn the casting behavior if either operand is not a number.

Operator | Name | Description | Example |
---|---|---|---|

+ | Addition | Adds two numbers. Can also concatenate two text values. | `5+5` |

- | Subtraction | Subtracts two numbers. | `5-5` |

* | Multiplication | Multiplies two numbers. | `5*5` |

/ | Division | Divides two numbers. | `5/5` |

% | Modulus | Returns the remainder of a number divided by another number. | `10 % 2` |

++ | Increment by one | Increments a number variable by one. | `x++` or `++x` |

-- | Decrement by one | Decrements a number variable by one. | `--x` or `x--` |

The increment/decrement by one operators have pre and post versions that differ in what they return. The pre increment version adds one to the variable and returns the new value while the post increment adds one and then returns the initial value of the variable.

```
// Pre increment example
var x = 10;
++x // x is now 11 and the value 11 is returned
// Post increment example
var x = 10;
x++ // x is now 11 but the value of 10 is returned.
```

## Assignment operators

Assignment operators are used to assign values to variables. See Type casting - Assignment statements to learn the implicit casting behaviors during variable assignment.

Operator | Name | Description | Example |
---|---|---|---|

= | Equals | Assigns a value to a variable. | `x = 10` |

+= | Add assign | Adds a number to the value of a number variable and assigns the result to the variable. | `x += 10` |

-= | Minus assign | Subtracts a number from a value of a number variable and assigns the result to the variable. | `x -= 10` |

*= | Multiply assign | Multiplies a number by the value of a number variable and assigns the result to the variable. | `x *= 10` |

/= | Divide assign | Divides the value of a number variable by another number and assigns the result to the variable. | `x /= 2` |

```
// Add assign
var x = 10;
x+=5 // x is now 15
```

## Comparison operators

Comparison operators compare the values of two numbers. See Type casting - Comparison statements to learn the casting behavior of either operand.

Operator | Name | Description | Example |
---|---|---|---|

== | Equal to | Evaluates to true if the x-value is equal to the y-value. | `x==y` |

!= | Not equal to | Evaluates to true if the x-value is not equal to the y-value. | `x!=y` |

> | Greater than | Evaluates to true if the x-value is greater than the y-value. | `x>` |

>= | Greater than or equal | Evaluates to true if the x-value is greater than or equal to the y-value. | `x>` |

< | Less than | Evaluates to true if the x-value is less than the y-value. | `x<` |

<= | Less than equal to | Evaluates to true if the x-value is less than or equal to the y-value. | `x<` |

Comparison operators attempt to coerce text to a number when comparing a text value to a number.
The `==`

and `!=`

operators don't do any coercion of types. If the types are different, then they are not equal.

```
10 == "10" // returns false
10 != "10" // returns true
10 > "10" // returns false
10 >= "10" // returns true
10 < "10" // returns false
10 <= "10" // returns true
9 < "10" // returns true
11 < "10" // returns false
```

For arrays, dictionaries, and geometry types, comparisons are a pointer check to see if they are the same object. Internal values of the object are not checked.

```
var a1 = [1,2,3]
var a2 = [1,2,3]
a1 == a2 // evaluates to false since they are not the same object.
a1 == a1 // evaluates to true since they are the same object.
```

Comparing DateOnly or Date values with Time values will throw an error.

## Logical operators

Logical operators specify whether two conditions should be grouped together or evaluated separately. See Type casting - Logical statements to learn the casting behavior if either operand is not a boolean.

Operator | Name | Description | Example |
---|---|---|---|

| | | Logical or | Returns `true` if one of two statements evaluates to `true` . | `if (x==9 || y==0)` |

&& | Logical and | Returns `true` if both statements evaluate to `true` . | `if (x==9 && y==0){}` |

! | Logical not | Returns `true` if the statement does not return `true` . | `if(!did` |

```
if(!IsEmpty($feature.MyField)){
return "This field has a value";
}
```

## Unary operators

Unary operators indicate if a value is positive or negative. See Type casting - Unary statements to learn the casting behavior if either operand is not a number.

Operator | Description | Example |
---|---|---|

+ | Returns the value. | +10 |

- | Negates the value. | -10 |

## Bitwise operators

Bit operators work with 32 bit numbers.

Operator | Name | Description | Example |
---|---|---|---|

& | Bitwise AND | Returns a `1` in each bit position for which the corresponding bits of both operands are `1` s. If either bit of one of the operands is `0` , the corresponding bit of the result is also `0` . | `a & b` |

| | Bitwise OR | Returns a `1` in each bit position for which the corresponding bits of either or both operands are `1` s. | `a | b` |

^ | Bitwise XOR | Returns a `1` in each bit position for which the corresponding bits of either but not both operands are `1` s. | `a ^ b` |

~ | Bitwise NOT | Inverts the bits of its operand. Bits that are `0` become `1` and bits that are `1` become `0` . Bitwise NOTing any number `x` yields `-(x+1)` | `~ a` |

<< | Left shift | Shifts `a` in binary representation `b` (< 32) bits to the left, shifting in `0` s from the right. | `a <` |

>> | Sign propagating right shift | Shifts `a` in binary representation `b` (< 32) bits to the right, discarding bits shifted off, and shifting in copies of the leftmost bit from the left. | `a >` |

>>> | Zero fill right shift | Shifts `a` in binary representation `b` (< 32) bits to the right, discarding bits shifted off, and shifting in `0` s from the left. The sign bit becomes `0` , so the result is always non-negative. | `a >` |

Bitwise operators will perform their operation on the binary representation of the number provided to the operator, and will return a standard numerical value.

```
7 & 14
// converts to 0111 and 1110
// result is 0110, which returns 6
7 | 14
// result is 1111, which returns 15
7 ^ 14
// result is 1001, which returns 9
~ 7
// converts to 00000000000000000000000000000111
// result is 11111111111111111111111111111000 (inverted operand)
// returns -8
7 << 2
// shift 00000000000000000000000000000111 two bits to the left
// result is 00000000000000000000000000011100
// returns 28
7 >> 2
// shift 00000000000000000000000000000111 two bits to the right
// result is 000000000000000000000000000001
// returns 1
-7 >> 2
// shift 11111111111111111111111111111001 two bits to the right
// result is 11111111111111111111111111111110
// returns -2
-7 >>> 2
// shift 11111111111111111111111111111001 two bits to the right
// result is 00111111111111111111111111111110
// returns 1073741822
```