JavaScript has a variety of operators, which can be categorized into several types. Here are the main types of operators in JavaScript, along with examples.

1. Arithmetic Operators

Arithmetic operators are used to perform mathematical operations.

Addition (+) : Adds two numbers.
let sum = 5 + 3; // sum is 8
let concat = 'Hello' + ' ' + 'World'; // concat is 'Hello World'
                        
Subtraction (-) : Subtracts the second number from the first.
let subtraction = 5 - 3; // subtraction is 2
let subtraction = 15 - 5; // subtraction is 10
                        
Multiplication (*) : Multiply first and second number.
let multiplication = 5 * 3; // multiplication is 15
let multiplication = 4 * 6; // multiplication is 24
                        
Division (/) : Divide two numbers.
let division = 5 / 3; // division is 1.6666666667
let division = 25 / 5; // division is 5
                        
Modulus (%) : Returns remainder of the number.
let remainder = 5 % 2; // remainder is 1
let remainder = 10 % 2; // remainder is 0
                        

2. Comparison Operators

Comparison operators are used to compare two values and return a boolean value (true, false).

Equal to (==) : Checks if two values are equal.
let isEqual = 5 == '5'; // isEqual is true
let isEqualStrict = 5 === '5'; // isEqualStrict is false (strict equality)
                        
Greater than (>) : Checks if the first value is greater than the second.
let isGreater = 10 > 5; // isGreater is true
let isGreater = 2 > 5; // isGreater is false
                        
Less than (<) : Checks if the first value is less than the second.
let isLesser = 2 < 5; // isLesser is true
let isLesser = 10 < 5; // isLesser is false
                        
Greater than or Equal to (>=) : Checks if the first value is greater than or equal to the second.
let isGreaterThanOrEqualTo = 10 >= 5; // isGreaterThanOrEqualTo is true
let isGreaterThanOrEqualTo = 2 >= 5; // isGreaterThanOrEqualTo is false
                        
Less than or equal to (<=) : Checks if the first value is less than or equal to the second.
let isLesserThanOrEqualTo = 2 <= 5; // isLesserThanOrEqualTo is true
let isLesserThanOrEqualTo = 10 <= 5; // isLesserThanOrEqualTo is false
                        

3. Logical Operators

Logical operators are used to combine two or more conditions.

Logical AND (&&) : Returns true if both conditions are true.
if (true && true) // true
let andResult = (5 > 3) && (10 > 5); // andResult is true
if (true && false) // false
let andResultFalse = (5 > 3) && (5 > 10); // andResultFalse is false
if (false && true) // false
let andResultFalse = (3 > 5) && (10 > 5); // andResultFalse is false
                        
Logical OR (||) : Returns true if at least one condition is true.
if (true || true) // true
let orResult = (5 > 3) || (10 > 5); // orResult is true
if (true || false) // true
let orResult = (5 > 3) || (5 > 10); // orResult is true
if (false || false) // false
let orResultFalse = (5 < 3) || (15 < 10); // orResultFalse is false
                        
Logical NOT (!) : Returns true if the condition is false.
if (!false) // true
let andResult = (5 != 3); // andResult is true
if (!true) // false
let andResultFalse = (5 != 5); // andResultFalse is false
                        

4. Assignment Operators

Assignment operators are used to assign values to variables.

Assignment (=) : Assigns the right-hand operand to the left-hand operand.
let x = 10; // x is 10
let y = 'Hello'; // y is 'Hello'
                        
Addition assignment (+=) : Adds the right-hand operand to the left-hand operand and assigns the result to the left-hand operand.
let x = 5;
x += 3; // x is 8
let str = 'Hello';
str += ' World'; // str is 'Hello World'
                        
Subtraction assignment (-=) : Subtracts the right-hand operand from the left-hand operand and assigns the result to the left-hand operand.
let x = 10;
x -= 4; // x is 6
                        
Multiplication assignment (*=) : Multiplies the right-hand operand by the left-hand operand and assigns the result to the left-hand operand.
let x = 5;
x *= 3; // x is 15
                        
Division assignment (/=) : Divides the left-hand operand by the right-hand operand and assigns the result to the left-hand operand.
let x = 10;
x /= 2; // x is 5
                        
Modulus assignment (%=) : Takes the modulus using the right-hand operand and assigns the result to the left-hand operand.
let x = 10;
x %= 3; // x is 1
                        

5. Unary Operators

Unary operators operate on a single operand to produce a new value.

Unary plus (+) : Converts a variable to a number.
let x = '5';
x = +x; // x is 5 (number)
                        
Unary minus (-) : Negates a number.
let x = 5;
x = -x; // x is -5
                        
Increment (++) : Increases a variable’s value by one.
let x = 5;
x++; // x is 6
                        
Decrement (--) : Decreases a variable’s value by one.
let x = 5;
x--; // x is 4
                        
Logical NOT (!) : Reverses the logical state of its operand.
let isTrue = true;
isTrue = !isTrue; // isTrue is false
                        

6. Conditional (Ternary) Operator

The conditional (ternary) operator is a shorthand for an `if-else` statement.

Conditional (?:) : Evaluates a condition and returns one of two values.
let age = 18;
let isAdult = (age >= 18) ? 'Yes' : 'No'; // isAdult is 'Yes'