# JavaScript Operators: The Basics You Need to Know

Operators in JS is the tool to play with values. like if you want to do some actions or calucations with values the js provides the Opertors like +,=,x ,/ and some more Basic opertaions like:

### Arithmetic Operations for Calculations

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

console.log(a + b); // 13 (addition)
console.log(a - b); // 7  (subtraction)
console.log(a * b); // 30 (multiplication)
console.log(a / b); // 3.33 (division)
console.log(a % b); // 1 (remainder)
```

### Assignment Opertations

Used to assign or update values like:

```javascript
let num = 10; // Assigining the values
// if we use  Arithmetic  then we can update assigned values
num += 5; // num = num + 5 → 15
num -= 3; // num = num - 3 → 12
```

### Comparion Operations

this is intersting things let discuss

```javascript
// like as earlier discussed
let a = 5 // single '='  is used for assign the value
let b = '5' // assigning number as string right?

// now '==' is used to compare the values
console.log(a == b) // true

// also '===' is used for compare value and its type
console.log(a ===b) // false because its number and string 
```

> Let know some more things

```javascript
let a = 5
let b = 10
// '<' '>' '!'
console.log(a > b) // false "is a is greater then b"
console.log(a < b) // true "is a is let then b"
console.log(a != b) // false "check for not eqal"
// ! is used for false or not.
```

### Logical Opertaions

let go for more deeper for comparing values with combined coditions. Just Remember :

*   `&&` is used **AND** conditions
    
*   `||` is used for **OR** condtions
    
*   `!` is used to check the not or falsy values
    

```javascript
let age = 20;

console.log(age > 18 && age < 30); // true
console.log(age < 18 || age > 15); // true
console.log(!(age > 18)); // false
// go slow and revise it. there is 2 condtions which compared so 
//"&&" is used to check the both condtion is true and 
// "||" is used for to check at least 1 condition the true 
// "!" is checkign condition is false and it make opposite whatever condition is.
```

| A | B | A && B | A || B | ! for A |
| --- | --- | --- | --- | --- |
| true | true | true | true | false |
| true | false | false | true | false |
| false | true | false | true | true |
| false | false | false | false | true |

### Summary

JS is tools to play with data with some operators like

*   Use `+ - * / %` for math
    
*   Use `===` instead of `==`
    
*   Use `&&` and `||` for combining conditions
    
*   Use `+=`, `-=` for cleaner updates
    

*   AND (`&&`) → strict (needs both true)
    
*   OR (`||`) → flexible (needs one true)
    
*   NOT (`!`) → reverses result
