What are the different types of operators in JavaScript 2021

In this article, we discuss What are the different types of operators in JavaScript

What are the different types of operators in JavaScript

What are the different types of operators in JavaScript
What are the different types of operators in JavaScript

What are the different types of operators in JavaScript

An operator is used for manipulating a certain value or operand. Operators are used to perform specific mathematical and logical computations on operands. In this article, we will discuss about different JavaScript Operators and how they are used in a code in the following sequence:

  • What is an Operator?
  • Types of JavaScript Operators
    • Arithmetic Operators
    • Comparison Operators
    • Bitwise Operators
    • Logical Operators
    • Assignment Operators

What is an Operator?

Operators are used for comparing values, perform arithmetic operations, etc. For example, if we take a simple expression, 4 + 5 is equal to 9. Here 4 and 5 are called operands and ‘+’ is called the operator. JavaScript consists of different types of operators that are used to perform different operations.

What are the different types of operators in JavaScript

Types of JavaScript Operators

There are different types of operators in JavaScript that are used for performing different operations. Some of the JavaScript Operators include:

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

Arithmetic Operators

Arithmetic operators are used to perform arithmetic operations on the operands. Here is a list of operators that are known as JavaScript arithmetic operators:

peratorDescriptionExample
+Adds two operands10 + 20 = 30
Subtracts the second operand from the first30 – 20 = 10
/Divide the numerator by the denominator20/10 = 2
*Multiply two operands5 * 5 = 25
%Outputs the remainder of an integer division20 % 10 = 0
++Increases an integer value by onevar a=20; a++; Now a = 21
Decreases an integer value by onevar a=20; a–; Now a = 19
What are the different types of operators in JavaScript

What are the different types of operators in JavaScript

Comparison Operators

The JavaScript comparison operator compares the two operands. The comparison operators are as follows:

OperatorDescriptionExample
==Checks if two operands are equal or not. If yes, then the condition becomes true.20==30 = false
===Finds the identical (equal and of the same type)10===20 = false
!=Checks if two operands are equal or not. If the values are not equal, then the condition becomes true20!=30 = true
!==It implies that two values are not Identical20!==20 = false
>Checks if the value of the left operand is greater than the value of the right operand30>10 = true
>=Checks if the value of the left operand is greater than or equal to the value of the right operand20>=10 = true
<This Checks if the value of the left operand is less than the value of the right operand20<10 = false
<=Checks if the value of the left operand is less than or equal to the value of the right operand30<=10 = false
What are the different types of operators in JavaScript

What are the different types of operators in JavaScript

Bitwise Operators

The bitwise operators are used to perform bitwise operations on operands. Here is a list of bitwise operators:

OperatorDescriptionExample
&Boolean AND operation on each bit of its integer arguments(10==20 & 20==33) = false
|It performs a Boolean OR operation on each bit of its integer arguments(10==20 | 20==33) = false
^This operator performs Bitwise XOR operation(10==20 ^ 20==33) = false
~It is a unary operator and operates by reversing all the bits in the operand(~10) = -10
<<Moves all the bits in its first operand to the left by the number of places specified in the second operand.(10<<2) = 40
>>The left operand’s value is moved right by the number of bits specified by the right operand.(10>>2) = 2
>>>This operator is just like the >> operator, except that the bits shifted in on the left are always zero.(10>>>2) = 2
What are the different types of operators in JavaScript

Logical Operators

The list provides all the  JavaScript logical operators:

OperatorDescriptionExample
&&Logical AND – If both the operands are non-zero, then the condition becomes true(10==20 && 20==33) = false
||Logical OR – If any of the two operands are non-zero, then the condition becomes true.(10==20 || 20==33) = false
!Logical NOT – Reverses the logical state of its operand.!(10==20) = true
What are the different types of operators in JavaScript

Assignment Operators

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

OperatorDescriptionExample
=Assigns values from the right side operand to the left side operand20+10 = 30
+=It adds the right operand to the left operand and assigns the result to the left operandvar a=20; a+=10; Now a = 30
-=It subtracts the right operand from the left operand and assigns the result to the left operandvar a=30; a-=10; Now a = 20
*=It multiplies the right operand with the left operand and assigns the result to the left operandvar a=10; a*=20; Now a = 200
/=It divides the left operand with the right operand and assigns the result to the left operandvar a=10; a/=2; Now a = 5
%=It takes modulus using two operands and assigns the result to the left operandvar a=10; a%=2; Now a = 0
What are the different types of operators in JavaScript

Source: Various

Also Check out What is a JavaScript Variable and How to declare it?

If you interested in Entertainment genre please check this also Deepika Padukone Age, Biography, Wiki, Family, Filmography & More

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

How to Protect yourself from CovidVaccination saves lives at every stage of life
  • Clean your home regularly, particularly frequently touched surfaces like
  • Stay home stay safe. Follow the Golden Rule. Wash your hands frequently with soap and water or use alchohol based hand-rub.
  • Stay home stay safe. Stay physically fit. Exercise regulary. Eat a nutritious diet. Don’t smoke.
  • Stay home stay safe. If you show symptoms of COVID-19, self isolate yourself, wear a mask around others and seek medical advice