 # Javascript Operators

In this lecture, we will discuss different JavaScript operators. An operator is used to manipulate a specific value or operand. Operators are used to perform precise mathematical and logical calculations on operands.

## What is a Operator?

Operators are used to compare values, perform arithmetic operations, etc. For example, if we take a simple equation, 10 + 11 is equal to 21. Here 10 and 11 are called operand and ‘`+`’ is called operator.

JavaScript includes different types of operators that are used to perform different operations.

## Types of JavaScript Operators

JavaScript has different types of operators that are used to perform different operations. Which are as follows

• Arithmetic Operators
• Assignment Operators
• Logical Operators
• Comparison Operators
• Bitwise Operators

## JavaScript Arithmetic Operators

Arithmetic operators are used to perform arithmetic operations on the operand. The following operators are known as JavaScript arithmetic operators.

Operator Name Example
+ Addition 5 + 5 = 10
- Subtraction 10 - 5 = 5
* Multiplication 4 * 2 = 8
/ Division 10 / 2 = 5
% Modulus 20 % 10 = 0
++ Increment a = 5; a++; a = a;
-- Decrement a = 5; a--; a = a;
** Exponentiation x = 5; x**2; x = 25

## JavaScript Assignment Operators

Assignment operators are used to assign values to the operand. The following operators are known as JavaScript assignment operators.

Operator Name Example
= Assign 10 + 5 = 15
+= addition a = 10; a += 5; a =15;
-= Subtraction a = 10; a -= 5; a =5;
*= Multiplication a = 10; a *= 10; a =100;
/= Division a = 10; a /= 2; a =5;
%= Modulusassign a = 10; a %= 2; a = 0;

## JavaScript Logical Operators

Logical operators are used in decision making and loops. The list of logical operators is as follows.

Operator Name Example
&& logical and 20==30 && 30==33 = false
|| Logical OR 20==30 || 30==33 = false
! Logical NOT !(20==30) = true

## JavaScript Comparison Operators

JavaScript comparison operator compares two operand. The comparison operators are as follows.

Operator Name Example
== Equal to 10==20 = false
!= Not equal 10!=20 = true
=== Identical 10==20 = false
!== Not Identical 10!==10 = false
< Less than 20 < 10 = false
<= Less than or Equal to 20 <= 10 = false
> Greater than 20 > 10 = true
>= Greater than or Equal to 20 >= 10 = true

## JavaScript Bitwise Operators

Beatwise operators are used to perform bitwise operations on Operand. The following is a list of bitwise operators.

Operator Name Example
& Bitwise AND 10==15 & 20==25 = false
| Bitwise OR 10==15 | 20==25 = false
^ Bitwise XOR 10==20 ^ 20==40 = false
~ Bitwise NOT ~10 = -10
<< Left Shift 10 << 1 = 20
>> Right Shift 10 >> 2 = 2
>>> Right Shift with Zero 10 >>> 2 = 2