# JS Operators

### The Arithmatic Operators:

The Arithmetic Operators are used with numeric operands and returns a numerical value. There are following arithmatic operators supported by JavaScript language:

Let assume variable a=5 and variable b=10.

Operator | Description | Example |
---|---|---|

+ | Addition | a + b = 15 |

– | Subtraction | a – b = -5 |

* | Multiplication | a * b = 50 |

/ | Division | b / a = 2 |

% | Modulus (division remainder) | b % a = 0 |

++ | Increment | a++ = 6 |

— | Decrement | a– = 4 |

### The Assignment Operators:

There are following assignment operators supported by JavaScript language:

Let assume variable a=20 and variable b=10.

Operator | Example 1 | Same As Example 1 | Result |
---|---|---|---|

= | a=b | a = 10 | |

+= | a+=b | a=a+b | a = 30 |

-= | a-=b | a=a-b | a = 10 |

*= | a*=b | a=a*b | a = 200 |

/= | a/=b | a=a/b | a = 2 |

%= | a%=b | a=a%b | a = 0 |

### The Comparison Operators:

There are following comparison operators supported by JavaScript language:

Let assume variable a=2 and variable b=3.

Operator | Description | Example | Result |
---|---|---|---|

== | is equal to | a == b | is not true |

!= | is not equal | a != b | is true |

> | is greater than | a > b | is not true |

< | is less than | a < b | is true |

>= | is greater than or equal to | a >= b | is not true |

<= | is less than or equal to | a <= b | is true |

### The Logical Operators:

There are following logical operators supported by JavaScript language:

Let assume variable a=5 and variable b=8.

Operator | Description | Example | Result |
---|---|---|---|

&& | and | (a && b) | is true |

|| | or | (a || b) | is true |

! | not | !(a && b) | is false |