Types of Operators:
- Arithmetic Operator
- Boolean Operator
- Increment & Decrement Operator
- Comparison Operator
- Conditional Operator
- Logical Operator
Arithmetic Operator:
- Arithmetic operators are used basic mathematical operations.
- They usually have two operands and one operator.
Operators: + , - , * , / , % , **
(10 + 5);    // 15 (Addition Operator)
(5 - 3);     //2  (Subtraction Operator)
("10" + 5);  // "105" (string + number → concatenation)
("10" - 5);  // 5   (string converted to number automatically)
- JavaScript is a dynamically typed language, so it automatically converts numeric strings into numbers when needed.
- If you want to manually convert a string to an integer → use parseInt().
(10 * 2);    // 20 (Multiplication Operator)
(10 / 2);    // 5 (Division Operator)
(10 % 2);    // 0 Modulus (remainder)
(2 ** 3);    // 8  (2*2*2)  (Exponentiation Operator)
Boolean Operator:
- Boolean has only two values:
- true or false. 
- In boolean value True is 1. 
- In boolean value False is 0. 
 Example:
- true+1 =2 
- false-2 =-2 
Increment & Decrement Operator
PostIncrement:(i++)
It first assign the value and then increase.
Example:
i=5;
log(i++);//5(value )
log(i);//6 (increase)
Postdecrement:(i--)
It first assign the value and then decrease.
Example:
 i=5;
 log(i--);//5 (value )
 (i--);//4 (decrease)
Preincrement:(i--)
It first increase the value and then assign.
Example:
i=5;
++i;
log(i);//6
Predecrement:(i--)
 It first decrease the value and then assign.
** Example: **
i=5;
--i;
log(i);//4
Comparsion Operator
    Compare both the value and return the boolean value true or false .
Example:
== Method
5==5 //true
"5"==5(In this case it return the true value because it check only the values not the datatypes)
=== Method
"5"=== 5 // false
"5"===5 (In this case it return the flase value because it check both the values and the datatypes)
Greaterthan Operator & lessthan Operator(>,<)
Example:
7>5//True
5<7//true
Greaterthan or equal to Operator & lessthan or equal to Operator(>=,<=)
Example:
5<=5//true
Logical Operator
OR ->||
AND ->&&
NOT ->!
OR(||) :
- If any one condition is true it return true.
Example:
5<5   ||   4>2  // true (any one true it return true)
false     true
AND(&&):
- It return true only when Both the condition are true.Otherwise it return flase.
Example:
5<5 && 4>2 // true (both condition are true then only return true otherwise false)
 

 
    
Top comments (0)