# Javascript Operators

Written By: Avinash Malhotra

Updated on

**Articles Ratings →**

**4.5**out of

**5**based on

**3**ratings.

## JavaScript Operators

**Javascript Operators** are used to assign, add, subtract, compare variables value. JavaScript is having **Artimetic**, **logical**, **assignment** and **comparision** operators.

JavaScript has **binary**, **unary** and **ternary**operators.

**Binary operators** required two operands, one before and one after operator. ` x+y=z`

**Unary operators** required only one operand, either before or after operator. ` i++`

### Type of Operators in Javascript

## Arithmetic Operators

An **Arithmetic operator** is used to perform **Arithmetic operations** between values. Like Addition, Subtraction, Multiplication, Division etc

### Arithmetic operators in JavaScript

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

+ | Addition | 2+3=5 |

- | Subtraction | 5-3=2 |

* | Multiply | 2*3=6 |

/ | Divide | 6/3=2 |

% | Modulus, check reminder | 6%3=0 |

++ | Increment, y++ means y = y+1 | var y=2; ++y; y=3 |

-- | Decrement, y-- means y = y-1 | var y=2; --y; y=1 |

## Logical Operators

**Logical Operators** are used to check logic between two operators. **and (&&)**, ** or (||)** and **not (!)** are logical operators.

### Logical Operators in JavaScript

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

&& | and, when both are correct | 2 < 5 && 2> 1 is true |

|| | or, when any one is correct | var x=2, 2>5 || x==2 is true |

! | not | !(2==3) is true |

## Assignment Operators

**Assignment operators** ars used to assign some value to js variables. =, +=, -=, *=, /= are all **assignment operators in javascript.**

### Assignment Operators in JavaScript

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

= | Assignment | x=2; means x is 2 |

+= | Addition Assignment | var x=2; x+=2 means x=x+2 |

-= | Subtraction Assignment | var x=2; x-=2 means x=x-2 |

*= | Multiplication Assignment | var x=2; x*=2 means x=x*2 |

/= | Division Assignment | var x=2; x/=2 means x=x/2 |

## Comparision Operators

**Comparision operators** are used in a statement to compare two values.

### Comparision Operators in JavaScript

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

== | Equal to | 2=="2" is true |

=== | Strict equal to | 2==="2" is false |

!= | not equal | 2!=1 is true |

!== | not strict equal | 2!=="2" is true |

> | greater than | 2> 5 is false, & 2 <5 is true |

>= | greater than or equal to | 3>=3 is true |

< | less than | 1< 3 is true |

<= | less than or equal to | 2<=2 is true |