Documentation
Back to website >

Basics of operators (JScript)

JScript is divided into arithmetic, logical, bitwise and assignment operators.

Arithmetic operators

Symbol Description Excample
- subtraction and negative number 500
a-b
-- Decrement (decrement by one). The symbol can be to the left or right of the variable.

var
  a=5;
  Ergebnis=--a

(The result in this case is 4)

+ addition and positive number +500
5+1
++ Increment (by one). The symbol can be to the left or right of the variable.

var
  b=5
  Ergebnis=++5

(The result in this case is 6)

* multiplication Result=4*5
/ division Result=10/2

Logical Operators

Symbol Description Excample
! Logical NOT Result=!false
< Smaller than Result=5<6
> Bigger than Result=6>5
<= Less than or equal to Result=5<=5
>= Greater than or equal to Result=5>=5
== Similarity Result=5=5
!= Not equal Result=5!=6
&& Logical AND (=UND)  
|| Logical OR (=OR)  
?: Three-part condition Result=6>7?"true":"false"
, decimal point i++, j++

Bitwise operators

Symbol Description Excample
~ Bitwise NOT  
< Bitwise shifting to the left  
>> Bitwise shifting to the right  
>>> Slide to the right without sign  
& Bitwise AND (=UND)  
^ Bitwise XOR (=exclusive OR)  
| Bitwise OR (=OR)  

Assignment Operators

Symbol Description Excample
= allotment Result=4*5
(op)= Connected assignment
+=, -=, *=, /=, %=, <<<=,>>=, >>>=, &=, |=, ^=

var
  Result=2
  Result+=4

(Result contains the value 6)

Priority Rules

All operations are processed in a priority order. The following table shows the sequence with the highest priority at the beginning.

Symbol Description
. [] () Field access, data field indexing and function calls
++ -- - ~ ! typeof new void Unary operators, return data type, object creation, undefined values
* / % Multiplication, Division, Modulo Division
+ - + Addition, subtraction, string linking
<<>>> >>> bit shift
< <> >= Less than, Less than equal, Greater than, Greater than equal
== != Equality, Inequality
& Bit-wise AND
^ Bit-wise XOR
| Bit-wise OR
&& Logical AND
|| Logical OR
?: terms
OP= Assignment, assignment with operation
, Multiple evaluation

The priority rule can be influenced by parenthesis.

Result=50*1+3
gives 53
Result=50*(1+3)
gives 200