Intro to JavaScript | Variables | Operators | Functions | If/else | For loops | Events

Operators

There are 2 types of operators in JavaScript.
Assignment operators and arithmetic operators.
The tables below describes and shows examples of the operators.
Arithmetic

a=1+7;a=8a=8*3;
OperatorDescriptionExampleResult
+Addition
-Subtractiona=8-2;a=6
*Multiplicationa=24
/Divisiona=21/3;a=7
%Modulusa=20%7;a=6
++Incrementa++;a=a+1
--Decrementa--;a=a-1
Assignment
OperatorDescriptionExampleResult
=Assignmenta=8a=8;
+=Add rightside value to original valuea=1; a+=7;a=8
-=Subtract rightside value from original valuea=8; a-=2;a=6
*=Multiply rightside value to original valuea=8; a*=3;a=24
/=Divide leftside value by rightside valuea=21; a/=3;a=7
%=Same as divide, but output the modulusa=20; a%=7;a=6