DEV Community

Megha M
Megha M

Posted on

Fun Operators of JavaScript – Compare & Conquer!

Today’s JavaScript class was super fun because I got to learn some of the coolest things that make JavaScript smart comparison and logical operators. These operators may look small, but they help our code make decisions like a pro! Let me explain what I learned in a fun and simple way.

What Are These Operators?

  • Comparison Operators – These compare two values and answer with either true or false.

  • Logical Operators – These help check multiple conditions together using logic.

Meet the Comparison Operators

  • "10" == 10 true → Only value matters here
  • "10" === 10 false → Value and type both must match
  • 5 != 3 true → They are not the same
  • 5 !== "5" true → Same value, different type
  • 7 > 5 true → 7 is greater
  • 3 < 6 true → 3 is smaller
  • 4 >= 4 true → 4 is equal or more
  • 2 <= 1 false → Nope, 2 is not less than or equal to 1

Logical Operators – Teamwork Time!

  • &&(AND) → Both must be true age > 18 && city == "Chennai" → Only true if both are correct
  • || (OR) → Any one condition can be true marks > 35 || attendance > 75→ If either is true, you pass

Mini Game: Guess the Output!

Let’s play! Try guessing before checking:1️

  1. "10" == 10 → true
  2. "10" === 10 → false
  3. 5 != 3 → true
  4. 7 > 5 && 2 < 3 → true
  5. 10 === "10" || 5 < 3 → false

✅ Got 5/5? You’re an Operator Champ!

What I Learned

Today’s topic helped me understand how decisions happen inside a program. These tiny operators are powerful when used in if-else, validations, and loops.

Top comments (1)

Collapse
 
sevaki_rajasekar_700822f9 profile image
Sevaki Rajasekar

🥴👏

Some comments may only be visible to logged-in visitors. Sign in to view all comments.