# Operators and Their Types in JavaScript

A specific value or operand is manipulated with an operator. In order to carry out specified mathematical and logical operations on operands, operators are employed. We will go through several JavaScript operators and how to utilize them in a code snippet in this tutorial. Get career transformation to the web development domain by learning in our JavaScript Course in Chennai with placement assistance at Softlogic Systems.

## What is an Operator?

Operators are used to execute arithmetic operations, compare values, and more. For instance, if we use a straightforward formula, 4 Plus 5 equals 9. Here, “+” is referred to as the operator, and the operands are 4 and 5. Different sorts of operators are included in JavaScript and are used to carry out various tasks.

## Types in JavaScript

In JavaScript, there are many types of operators that are used to carry out various operations. Some of the JavaScript operators are as follows:

• Arithmetic Operator
• Comparison Operator
• Bitwise Operator
• Logical Operator
• Assignment Operator

### Arithmetic Operator

The operands are applied to arithmetic operations through the use of arithmetic operators. The following operators are referred to as JavaScript arithmetic operators:

 Operator Description Example + To add two operands 12 + 12 = 24 – To subtract the second from the first operand 42 – 10 = 32 / To divide the number by the denominator 10/5 = 2 * To multiple two operands 2 * 2 = 4 % To display the remainder 5%2 = 1 ++ To increase the values by one If a = 2, then a++ = 3 — To decrease the values by one If a = 2, then a– = 1

### Comparison Operator

The two operands are compared by the JavaScript comparison operator. These are the comparison operators:

 Operator Description Example = = To evaluate whether or not two operands are equal. If the answer is yes, the condition is met. 7 = = 3 = false === To find the identical 1 == 2 = false != Todetermine whether or not two operands are equal. When the values are not equal, the condition is fulfilled. 2!=1 = true !== The implication is that two values are not the same. 2!==2 = false > To determine if the left operand’s value is higher than the right operand’s value. 3 > 2 = true >= To determine if the left operand’s value is greater than or equal to the right operand’s value. 23 >= 23 = true < To determine if the left operand’s value is smaller than the right operand’s value. 3 < 2 = false <= To determine if the left operand’s value is less than or equal to the right operand’s value. 3 <= 3 = true

### Bitwise Operator

Bitwise operations on operands are carried out using the bitwise operators. These bitwise operators are listed below:

 Operator Description Example & Each bit of its integer parameters is subjected to a boolean AND operation. (1 == 2 & 2 == 3) = false | On each bit of each of its integer parameters, it does a Boolean OR operation. (1 == 1 | 2 == 3) = true ^ Bitwise XOR action is carried out by this operator. (1 == 2 ^ 2 == 3) = false ~ It is a unary operator that functions by flipping every bit in the operand. (~1) = – 1 << the number of positions supplied in the second operand is used to shift all the bits in the first operand to the left. (1 << 2) = 4 >> The value of the left operand is shifted to the right by the number of bits indicated by the right operand. (1>>2) = 2 >>> The bits moved in on the left of this operator are always zero, unlike the >> operator. (1>>>2) = 2

### Logical Operators

All of the JavaScript logical operators are listed in the list:

 Operator Description Example && Logical AND – The condition is satisfied if both operands are non-zero (1 == 2 && 2 == 3) = false || Logical OR – If any of the two operands is non-zero, the condition is said to be logically true. (1 == 2 || 2 == 2) = true ! Logical Not – Reverses the operand’s logical state !(1 == 2) = true

### Assignment Operators

The operand can be given values by using the assignment operators. Assigning operators in JavaScript include the following:

 Operator Description Example = The left-side operand gets values from the right-side operand. 2 + 1 = 3 += It assigns the outcome to the left operand after adding the right operand to the left one a = 2; a+= 1; then, a = 3 -= It allocates the result to the left operand after subtracting the right operand from the left one a = 3, a-=1; then, a = 2 *= It adds the result to the left operand after multiplying the right and left operands. a = 1, a*= 2; then a = 2 /= The result is assigned to the left operand after the left operand and right operand are divided. a = 4, a/=2; then a = 2 %= It performs a modulus operation with two operands and transfers the outcome to the left operand. a = 5, a%=2; then a = 1

## Conclusion

Through this article, we hope you acquired knowledge about JavaScript operators. Join our JavaScript Training in Chennai with Best Practices at Softlogic Systems to gain practical experience with JavaScript operators.