Top JavaScript Operators: A Complete Guide

Top JavaScript Operators: A Complete Guide

Thu Apr 10 2025

You are living in a world where young people are showing interest in learning coding. It is most in demand. Are you also a JavaScript enthusiast? Yes? You are on the right platform. You have learned the plus, minus, division, and multiplication in school. But in computer science, you will learn all these calculations through JavaScript. In this blog, CollegeHai team is writing about JS operator. Here you can know Javascript operators in Hindi and English. So, let's get started.

Table of Content

JavaScript(JS) Operators

Just like other programming languages, JavaScript has a number of operators to carry out different tasks. The five major types of JavaScript operators are arithmetic, assignment, comparison, logical, and bitwise. In short, JavaScript operators are symbols that perform tasks on operands. The variables they work on are called operands. 

In Hindi: ऑपरेटर एक प्रतीक होते हैं जो किसी प्रक्रिया या ऑपरेशन को दर्शाते हैं। दूसरे शब्दों में, ऑपरेटरों का उपयोग किसी प्रक्रिया या ऑपरेशन को करने के लिए किया जाता है।

For instance: 

The result of adding 5 and 4 is 9.

 5 + 4 = 9.

 In this instance, ‘+’ is an operator and 5 and 4 are operands.

📜Javascript Operators List

What are JavaScript Operators.jpeg

Now you must be thinking about how many types of operators are there in JavaScript. Here, we will break down the most essential JavaScript operators from the basics (Arithmetic) to advanced (Logical and Bitwise operators). Let’s learn about each of them in detail using examples.

➕➖✖️➗Arithmetic Operators

Basic arithmetic operations are carried out on the operands using arithmetic operators. All of the arithmetic operators are as follows with the examples:

In Hindi: अंकगणितीय ऑपरेटर साधारण गणनाओं में उपयोग होने वाले ऑपरेटर होते हैं, जैसे कि जोड़, घटा, भाग, गुणा, आदि।

Operator 

Operator Meaning

Example

+

Addition

6+4=10

-

Subtraction

6-4=2

*

Multiplication

6*4=24

/

Division

6/4=1.5

%

Modulus (Remainder of Division)

6%4=0

++

Increment (Increase answer by 1)

var a=6; a ++; now a= 8

-

Decrement (Decrease answer by 1)

var a=6; a – -; now a=4

– Now have a look at the use of arithmetic operators in JavaScript.

<html>

   <body>

      <script type="text/javascript">

         <!--

            var a = 6;

            var b = 4;

            var c = "Test";

            var linebreak = "<br />";

         

            [removed]("a + b = ");

            result = a + b;

            [removed](result);

            [removed](linebreak);

         

            [removed]("a - b = ");

            result = a - b;

            [removed](result);

            [removed](linebreak);

 

            [removed]("a * b = ");

            result = a * b;

            [removed](result);

            [removed](linebreak);

 

            [removed]("a / b = ");

            result = a / b;

            [removed](result);

            [removed](linebreak);

         

            [removed]("a % b = ");

            result = a % b;

            [removed](result);

            [removed](linebreak);

         

            a = ++a;

            [removed]("++a = ");

            result = ++a;

            [removed](result);

            [removed](linebreak);

         

            b = --b;

            [removed]("--b = ");

            result = --b;

            [removed](result);

            [removed](linebreak);

         //-->

      </script>

      

      Set the variables to different values and then try...

   </body>

</html>

Output:

a + b = 10

a - b = 2

a * b = 24

a / b = 1.5

a % b = 0

++a = 8

--a = 4

➡️Assignment Operators 

Assignment operators are those operators in which the value, variable, and function are all assigned to another variable. The assignment operators are as follows.

In Hindi: असाइनमेंट ऑपरेटर (=) का उपयोग किसी वेरिएबल में वैल्यू असाइन करने के लिए किया जाता है। हालांकि, इसका उपयोग अंकगणितीय ऑपरेटरों के साथ भी किया जा सकता है, जैसा कि आप नीचे दिए गए उदाहरणों में देख सकते हैं।

Operator 

Operator Meaning

=

Assign

+=

Addition and Assign

=

Subtraction and Assign

*=

Multiplication and Assign

/=

Division and Assign

%=

Modulus and Assign

– Now have a look at the use of assignment operators in JavaScript.

<html>

   <body>

   

      <script type="text/javascript">

         <!--

            var a = 6;

            var b = 4;

            var linebreak = "<br />";

         

            [removed]("Value of a => (a = b) => ");

            result = (a = b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("Value of a => (a += b) => ");

            result = (a += b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("Value of a => (a -= b) => ");

            result = (a -= b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("Value of a => (a *= b) => ");

            result = (a *= b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("Value of a => (a /= b) => ");

            result = (a /= b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("Value of a => (a %= b) => ");

            result = (a %= b);

            [removed](result);

            [removed](linebreak);

         //-->

      </script>

   </body>

</html>

Explanation of the Code and Output

Assignment (a = b)

result = (a = b); assigns the value of b (4) to a.

The assignment operator returns the assigned value, so the result becomes 4.

Output: Value of a => (a = b) => 4

Addition Assignment (a += b)

result = (a += b); adds the value of b (4) to the current value of a (which is now 4) and assigns the result (8) back to a.

Output: Value of a => (a += b) => 8

Subtraction Assignment (a -= b)

result = (a -= b); subtracts the value of b (4) from the current value of a (8) and assigns the result (4) back to a.

Output: Value of a => (a -= b) => 4

Multiplication Assignment (a *= b)

result = (a *= b); multiplies the value of a (4) by the value of b (4) and assigns the result (16) back to a.

Output: Value of a => (a *= b) => 16

Division Assignment (a /= b)

result = (a /= b); divides the value of a (16) by the value of b (4) and assigns the result (4) back to a.

Output: Value of a => (a /= b) => 4

Modulo Assignment (a %= b)

result = (a %= b); calculates the remainder when a (4) is divided by b (4) and assigns the result (0) back to a.

Output: Value of a => (a %= b) => 0

🤔Comparison Operators

Logical operators include comparison operators to see the equality, inequality or difference of variables or values.

In Hindi: जावास्क्रिप्ट में तुलना ऑपरेटरों का उपयोग दो मूल्यों की तुलना करने के लिए किया जाता है। ये ऑपरेटर तुलना के परिणाम के आधार पर बूलियन मान (सही या गलत) लौटाते हैं।

Operator 

Operator Meaning

= = 

Equal to

!= 

Not equal

> 

Greater than

<

Less than

>=

Greater than or equal to

<=

Less than or equal to

– The use of comparison operators in JavaScript is demonstrated in the code that follows.

<html>

   <body>

   

      <script type = "text/javascript">

         <!--

            var a = 6;

            var b = 4;

            var linebreak = "<br />";

      

            [removed]("(a == b) => ");

            result = (a == b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("(a < b) => ");

            result = (a < b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("(a > b) => ");

            result = (a > b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("(a != b) => ");

            result = (a != b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("(a >= b) => ");

            result = (a >= b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("(a <= b) => ");

            result = (a <= b);

            [removed](result);

            [removed](linebreak);

         //-->

      </script>

         </body>

</html>

Explanation of the Code and Output

(a == b): 6 is not equal to 4, so the result is false.

Output: false

(a < b): 6 is not less than 4, so the result is false.

Output: false

(a > b): 6 is greater than 4, so the result is true.

Output: true

(a != b): 6 is not equal to 4, so the result is true.

Output: true

(a >= b): 6 is greater than or equal to 4, so the result is true.

Output: true

(a <= b): 6 is not less than or equal to 4, so the result is false.

Output: false

🚦Logical Operators

A logical operator is used to know whether a Boolean value is true or false.

In Hindi: तार्किक ऑपरेटर (Logical Operators) एक या एक से अधिक अभिव्यक्तियों (expressions) के आधार पर बूलियन मान (Boolean values) लौटाते हैं। बूलियन मान सत्य (true) या असत्य (false) हो सकता है। उदाहरण के लिए, आप एक प्रोग्राम लिख सकते हैं जो केवल तभी कुछ कार्य करता है जब कोई विशिष्ट स्थिति सत्य हो।

Operator 

Operator Meaning

&&

logical AND

|| 

logical OR

! 

logical Not

– Now have a look at the use of logical operators in JavaScript.

<html>

   <body>

   

      <script type="text/javascript">

         <!--

            var a = true;

            var b = false;

            var linebreak = "<br />";

      

            [removed]("(a && b) => ");

            result = (a && b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("(a || b) => ");

            result = (a || b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("!(a && b) => ");

            result = (!(a && b));

            [removed](result);

            [removed](linebreak);

         //-->

      </script>

      

   </body>

</html>

Explanation of the Code and Output

Logical AND (a && b)

a is true, and b is false.

The && (logical AND) operator returns true only if both operands are true.

Since b is false, the result is false.

Output: (a && b) => false:

Logical AND (a || b)

a is true, and b is false.

The || (logical OR) operator returns true if at least one operand is true.

Since a is true, the result is true.

Output: (a || b) => true:

Logical AND !(a && b)

(a && b) is false (as shown in the first output).

The ! (logical NOT) operator negates the operand.

Therefore, !(a && b) becomes ! false, which is true.

Output: !(a && b) => true: 

vBitwise Operators 

Bitwise operators use 32-bit numbers. Any numeric operand is transformed into a 32-bit number during operation. The outcome is converted back to a number by JavaScript.

In Hindi: बिट ऑपरेटर 32-बिट संख्याओं पर काम करते हैं। संचालन में, कोई भी संख्यात्मक ऑपरेंड 32-बिट संख्या में परिवर्तित हो जाता है। जावास्क्रिप्ट परिणाम को वापस एक संख्या में परिवर्तित करता है।

Operator 

Operator Meaning

&

Bitwise AND

| 

Bitwise OR

^ 

Bitwise XOR

~

Bitwise NOT

<<

Bitwise Left Shift

>>

Bitwise Right Shift

– Now have a look at the use of bitwise operators in JavaScript.

<html>

   <body>

   

      <script type="text/javascript">

         <!--

            var a = 6; // Bit presentation 10

            var b = 4; // Bit presentation 11

            var linebreak = "<br />";

         

            [removed]("(a & b) => ");

            result = (a & b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("(a | b) => ");

            result = (a | b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("(a ^ b) => ");

            result = (a ^ b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("(~b) => ");

            result = (~b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("(a << b) => ");

            result = (a << b);

            [removed](result);

            [removed](linebreak);

         

            [removed]("(a >> b) => ");

            result = (a >> b);

            [removed](result);

            [removed](linebreak);

         //-->

      </script>      

   </body>

</html>

Explanation of the Code and Output

a & b (Bitwise AND)

6 (110) & 4 (100) = 4 (100). The result is 1 only where both corresponding bits are 1.

Output: (a & b) => 4

a | b (Bitwise OR)

6 (110) | 4 (100) = 6 (110). The result is 1 if either of the corresponding bits is 1.

Output: (a | b) => 6

a ^ b (Bitwise XOR)

6 (110) ^ 4 (100) = 2 (010). The result is 1 if the corresponding bits are different.

Output: (a ^ b) => 2

~b (Bitwise NOT)

~4 (binary 100) is a bit more complicated because javascript uses 32-bit signed integers.

4 in 32-bit binary is 00000000000000000000000000000100.

~4 then becomes 11111111111111111111111111111011.

This is the two's complement representation of -5.

Output: (~b) => -5

a << b (Left Shift)

6 (110) << 4 shifts the bits of 6 four places to the left, filling in with zeros.

110 becomes 1100000.

This is 96 in decimal.

Output: (a << b) => 96

a >> b (Right Shift)

6 (110) >> 4 Shifts the bits of 6 four places to the right.

110 right shifted by 4 becomes 0.

This is 0 in decimal.

Output: (a >> b) => 0  

✅Conclusion

In the end, it is concluded that JavaScript includes operators like arithmetic, assignment, logical, and bitwise operators. You can have a basic understanding of all the JS operator through the collegeHai platform. The platform also provides you with examples of different operators in simple and easy language. Additionally, if you are not an English speaker, you can learn about JS operator in Hindi also.   

❓Frequently Asked Questions(FAQ)

1. What are JavaScript operators?

JavaScript operators are unique symbols that are used in scripts to carry out operations on operands. There are different types of operators in JS including value assignments, logical comparisons, and arithmetic computations.

2. How does the && operator work in JavaScript?

A logical operator that combines two or more conditions is the AND ( && ) operator in JavaScript. Only when every condition being assessed is true does it return true. The entire expression evaluates as false if any of the conditions are incorrect.

3. What is the purpose of the type of operator?

To ascertain the data type of a variable or expression, JavaScript’s type of operator (and comparable operators in other languages) returns a string that indicates the type, i.e., “string,” “number,” “boolean,” “object,” “function,” or “undefined.”

4. What does the "!" operator do in JavaScript?

Symbol  "!" denotes a logical operator which means ‘Not’.

5. What are string operators in JavaScript?

A string of characters is represented and worked with using the String object. String operators are used to concatenate values.

6. What are the 8 types of JavaScript?

The 8 types of JavaScript are number, string, boolean, null, undefined, bigInt, symbol, and object.

7. How many JavaScripts are there?

Basically JavaScript is used as a Language and as a JavaScript Ecosystem. JavaScript is used as a Language is a versatile, high-level programming language widely used for web development, but also for backend development with Node.js. JavaScript Ecosystem includes various tools, libraries, and frameworks that developers use to build web applications.

8. What are special operators in JavaScript?

Special operators in JavaScript include bitwise operators (e.g., &, |, ^), logical operators (&&, ||,!), and operators other than the usual arithmetic, assignment, and comparison operators.

9. Explain the operator in JavaScript in Hindi.

JavaScript में operators एक प्रतीक होते हैं जो किसी प्रक्रिया या ऑपरेशन को दर्शाते हैं। दूसरे शब्दों में, operators का उपयोग किसी प्रक्रिया या ऑपरेशन को करने के लिए किया जाता है।

Share with a friend.

Share on FacebookShare on TwitterShare on LinkedInShare on WhatsAppVisit us on Instagram