## Javascript Operators

Let us consider a simple expression. 7 + 5 equals 12 . The operands, in this case, are 7 and 5, and the operator, in this case, is '+.' The following operators are supported by JavaScript.

- Comparison Operators
- Arithmetic Operators
- Assignment Operators
- Ternary (Conditional) Operators
- Relational (Logical) Operators
- Bitwise Operators

Now, we'll be taking a look at each of these Javascript operators in detail. We'll be highlighting the operator, giving descriptions of each operator and examples of the operators.

### 1. Comparison Operators

For the examples under Comparison operators, assume variable X holds Five and variable Y has 10:

Operator | Description of Operator | Examples |

== | equal to | (X==Y) is false |

=== | equal value | (X===Y) is false |

> | greater than | (X>Y) is false |

< | less than | (X<Y) is true |

!= | not equal | (X!=Y) is true |

!== | not equal value | (X!==Y) is true |

>= | Greater than or equal to | (X>=Y) is false |

<= | less than or equal to | (X<=Y) is true |

? | Ternary Operator |

### 2. Arithmetic Operators

For the examples under Arithmetic operators, assume variable X holds Five and variable Y has 10:

Operator | Description of Operator | Examples |

+ | Addition | X+Y = 15 |

- | Subtraction | Y-X = 5 |

/ | Division | Y/X = 2 |

* | Multiplication | X*Y = 50 |

++ | Increment | X++ = 6 |

-- | Decrement | X-- = 4 |

% | Modulus or Remainder | Y%X = 0 |

### 3. Assignment Operators

= | Assigns the right operand's value to the left operand. |

+= | Sums up the left and right operand values and then assigns the result to the left operand. |

-= | Subtracts the right operand's value from the left operand's value and then assigns the result to the left operand. |

*= | Multiply both values and then assigns the result to the left operand. |

/= | Divide the left by the right operand value, and then assigns the result to the left operand. |

%= | Get the modulus of the left operand, divide it by the right operand, and assign the resulting modulus to the left operand. |

### 4. Ternary (Conditional) Operators

The conditional operator examines an expression to determine if it is true or false and then runs one of the given two statements based on the outcome of the evaluation.

Run this code to see how Conditional Operators work in JS:

<html> <body> <script type = "text/javascript"> <!-- var x = 20; var y = 30; var linebreak = "<br />"; document.write ("((x > y) ? 200 : 300) => "); result = (x > y) ? 200 : 300; document.write(result); document.write(linebreak); document.write ("((x < y) ? 200 : 300) => "); result = (x < y) ? 200 : 300; document.write(result); document.write(linebreak); //--> </script> <p>Run this code by TechStack...</p> </body> </html>

### 5. Relational (Logical) Operators

For the examples under Relational (Logical) operators, assume variable X holds Five and variable Y has 10:

Operator | Description of Operator | Examples |

|| | Logical OR | (X || Y) is true |

&& | Logical AND | (X && Y) is true |

! | Logical NOT | ! (X && Y) is false |

### 6. Bitwise Operators

Bit operators operate on numbers in 32 bits.

The operation converts any numeric operand into a 32-bit integer. The output is then returned as a JS number.

Operator | Description of Operator | Examples |

& | Bitwise AND | 10 & 5 same as 1010 & 0101 |

| | Bitwise OR | 10 | 5 same as 1010 | 0101 |

^ | Bitwise XOR | 10 ^ 5 same as 1010 ^ 0101 |

<< | Left Shift | 10 << 5 same as 1010 << 0101 |

>> | Right Shift | 10 >> 5 same as 1010 >> 0101 |

>>> | Right Shift + Zero | 10 >>> 5 same as 1010 >>> 0101 |

~ | Bitwise NOT | ~ 10 same as ~ 1010 |