Javascript Operators : The Basics you need to know!
The tiny symbols that make your JavaScript code think about the LOGIC and act with DECISIONS.

Let's get started ....
While writing the javascript code , we sometimes need to perform the actions like addition and multiplication of numbers , comparing the values and making some decisions . This all can be done using small symbols called as operators.
Even though these operators looks simple (= , - , === , % ) , they are known as the building blocks of javascript program . In this blog , we’ll explore the different types of operators and learn how they help our code think, calculate, and make decisions.
1] Arithmetic: The Engine Room: Powering Your Data
These are the basics you learned in school, but with a programming twist. They take two values and spit out a new one.
The types of Artithmetic operators are : Addition , Multiplication , Division , subtraction and Modulus.
The modulus operator gives you the remainder . in above eg. you can see 3%9 = 3; means 3 is the remainder . Another example you can take is 20%2 = 0; means 0 is the remainder .
Pro Tip: Use the Modulo operator (%) to check if a number is even or odd. If num % 2 is 0, it’s even!
2] Comparison operators
Comparison operators are used to compare two values or variables.
They check whether a condition is true or false and always return a Boolean value (true or false).
The comparison operators are : greater than , lesser than , not equal to , strict equal to , loose equal to.
"The Twin Paradox: Why == and === Aren't Friends"
The Loose Twin (
==)
The Double Equals is the "chill" friend. It doesn't care about types. If you try to compare a String "5" and a Number 5, it says, "I'll just convert one of these so they match. Close enough!" This hidden conversion is called Type Coercion
console.log(5 == "5"); // true (JavaScript forces them to match)
console.log(true == 1); // true (JavaScript treats 1 as true)
The Strict Twin (
===)
The Triple Equals is the "perfectionist" friend. It checks both the Value and the Data Type. If they aren't identical twins, it returns false. No conversions, no excuses.
console.log(5 === "5"); // false (One is a Number, one is a String)
console.log(true === 1); // false (One is a Boolean, one is a Number)
3] Logical: The Brain Center: Building Complex Conditions
These allow your code to make decisions. Think of them as the "Logic Gates" of your application.
The logical operators are : and , not , or
AND operator:
OR operator :
NOT operator :
4] Assignment: Code Shortcuts: Levelling Up Your Efficiency
You already know =, but did you know you can do math and assign a value at the same time? well yes you can ! all thanks to assignment operators .It saves space and looks cleaner.
var points = 10;
points += 5; // treated as: points = points + 5 (Result: 15)
points -= 3; // treated as: points = points - 3 (Result: 12)
SHORT SUMMARY FOR THE TOPICS YOU READ UNTILL NOW !
Category | Operator | Name | Rule / Logic | Real-World Example |
Arithmetic |
| Basic Math | Standard calculation. |
|
| Modulo | Finds the remainder. |
| |
Comparison |
| Loose | Checks value only. |
|
| Strict | Checks value + type. |
| |
Logical |
| AND | All must be true. |
|
| OR | At least one is true. |
| |
| NOT | Flips the truth. |
| |
Assignment |
| Shortcut | Math + Save result. |
|
THANK YOU !
