Documentation
Back to website >

Basics of operators (JScript)

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

Arithmetic operators

SymbolDescriptionExcample
-subtraction and negative number500
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)

*multiplicationResult=4*5
/divisionResult=10/2

Logical Operators

SymbolDescriptionExcample
!Logical NOTResult=!false
<Smaller thanResult=5<6
>Bigger thanResult=6>5
<=Less than or equal toResult=5<=5
>=Greater than or equal toResult=5>=5
==SimilarityResult=5=5
!=Not equalResult=5!=6
&&Logical AND (=UND)
||Logical OR (=OR)
?:Three-part conditionResult=6>7?"true":"false"
,decimal pointi++, j++

Bitwise operators

SymbolDescriptionExcample
~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

SymbolDescriptionExcample
=allotmentResult=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.

SymbolDescription
. [] ()Field access, data field indexing and function calls
++ -- - ~ ! typeof new voidUnary 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