Operator | Operation | Operand type | Position | Result type |
---|---|---|---|---|
~ | bitwise negation | Int | prefix | Int |
! | logical negation | Bool | prefix | Bool |
- | arithmetic negation | Float/Int | prefix | same as operand |
++ | increment | Float/Int | prefix and postfix | same as operand |
-- | decrement | Float/Int | prefix and postfix | same as operand |
The increment and decrement operators change the given value, so they cannot be applied to a read-only value. They also produce different results based on whether they are used as a prefix operator, which evaluates to the modified value, or as a postfix operator, which evaluates to the original value:
var a = 10; trace(a++); // 10 trace(a); // 11 a = 10; trace(++a); // 11 trace(a); // 11