# JavaScript Operators: The Basics You Need to Know

Now as we understand the meaning of variable and constant in previous blog. Now we are going to understand the meaning of operators and why we need them. Follow are the topics that we are going to cover inside this blog.

*   What operators are?
    
*   Arithmetic operators (+, -, \*, /, %)
    
*   Comparison operators (==, ===, !=, >, <)
    
*   Logical operators (&&, ||, !)
    
*   Assignment operators (=, +=, -=)
    

* * *

## What operators are...

Operators are the symbols which exhibit a specific meaning **in programming that represent specific mathematical, logical, or assignment actions performed on data, known as operands.**

* * *

## Arithmetic Operators (The Math Stuff)

These are used to perform basic mathematical calculations.

```plaintext
let a = 10;
let b = 3;

console.log(a + b); // Addition: 13
console.log(a - b); // Subtraction: 7
console.log(a * b); // Multiplication: 30
console.log(a / b); // Division: 3.333...
console.log(a % b); // Modulo (Remainder): 1 (because 3 goes into 10 thrice, with 1 left over)
```

* * *

## Comparison Operators (The Decision Makers)

Comparison operators check the relationship between two values and return `true` or `false`

The Big Difference: `==` vs `===`

*   `==` **(Loose Equality):** Checks only the **value**, ignoring the type. (e.g., `5 == "5"` is `true`).
    
*   `===` **(Strict Equality):** Checks both the **value AND the type**. This is the one you should use most often to avoid bugs.
    

```plaintext
let x = 5;
let y = "5";

console.log(x == y);  // true (Value is the same)
console.log(x === y); // false (Number vs String)
console.log(x != y);  // false (Loose "not equal")
console.log(10 > 5);  // true (Greater than)
console.log(3 < 1);   // false (Less than)
```

* * *

## Logical Operators (The "And/Or" Logic)

These allow you to combine multiple conditions together.

*   `&&` **(AND):** Returns `true` only if **both** sides are true.
    
*   `||` **(OR):** Returns `true` if **at least one** side is true.
    
*   `!` **(NOT):** Reverses the value (`true` becomes `false`).
    

```plaintext
let isAdult = true;
let hasTicket = false;

console.log(isAdult && hasTicket); // false (needs both)
console.log(isAdult || hasTicket); // true (needs at least one)
console.log(!isAdult);             // false (reverses true)
```

* * *

## Assignment Operators (The Shorthands)

Assignment operators are used to assign values to variables. You can also combine them with math to write shorter code.

```plaintext
let score = 10; // Simple assignment

score += 5; // Same as: score = score + 5 (Result: 15)
score -= 2; // Same as: score = score - 2 (Result: 13)

console.log(score); // 13
```

* * *

## Conclusion

Mastering these basics might feel small, but they are the constant "moving parts" in every complex app, from a simple calculator to a massive supply chain dashboard.
