DEV Community

SELVAKUMAR R
SELVAKUMAR R

Posted on

Operators in JavaScript

Arithematic Operator:

Addition (+):

This operator is used to summing the two number in program

Ex: 

10 + 5 = 15

"10"+5 = 105 >> when adding the string and number addition operator act as a **concatination** 

converting the string number in to number we using the function called **parseInt()** it convert only string number not a string.

parseInt("10"); -> 10

parseInt("Selva"); -> it shows the error NaN (Not a Number)

Enter fullscreen mode Exit fullscreen mode

Subtraction (-):

This operator is used to subtracting the two number in program

Ex:

10-5 = 5

"10"-5 = 5
Enter fullscreen mode Exit fullscreen mode

Multiplication(*):

This operator is used to multiplying the two number in program

Division (/):

This operator is used to return the quotent of the division two number

10/2 = 5
Enter fullscreen mode Exit fullscreen mode

Modulus (%):

This operator is used the return the reminder of the division two number

10%2 = 0
Enter fullscreen mode Exit fullscreen mode

Returning the Exponential Value ():**

Ex:
2**3 = 8
Enter fullscreen mode Exit fullscreen mode

Post increment operator (++):

let i = 10;
i++;
log(i); -> result : 11
Enter fullscreen mode Exit fullscreen mode

Post Decrement operator (--):

let i = 10;
i--;
log(i); result : 9
Enter fullscreen mode Exit fullscreen mode

Post Decrement operator (++i):

let i = 10;
++i;
log(i); result : 10
Enter fullscreen mode Exit fullscreen mode

Pre Decrement operator (--i):

let i = 10;
--i;
log(i); result : 9
Enter fullscreen mode Exit fullscreen mode

Comparision Operator :

==, ===, > , < , << , >>
Enter fullscreen mode Exit fullscreen mode

Logical Operator:

&& - And
|| - Or
!= - Not
Enter fullscreen mode Exit fullscreen mode

Top comments (0)