Unary Operators

Top  Previous  Next

Operators:  ~  !  +  -

Syntax:

~ expression

bitwise NOT

! expression

logical NOT

+ expression

unary plus

- expression

negation

 

The bitwise NOT operator ~ converts expression to Number, if necessary, and then converts it to internal integer format. Each of the 32 bits of the integer is inverted to produce the result of the operator.

 

The logical NOT operator ! converts expression to Boolean, if necessary. If expression evaluates to true then the result of the operator is false, otherwise the result is true.

 

The unary plus operator + converts expression to Number, if necessary. The result of the operator is the value.

 

The negation operator - converts the expression to Number, if necessary. The result of the operator is the value negated.