⚖️ Comparison Operators

Last Updated: 11th October 2025


Comparison operators are used to compare two values.
They return a Boolean valuetrue or false.

Hinglish Tip 🗣: Comparison ka matlab — “Dono values barabar hain ya nahi?”, “badi hai ya chhoti?”. Jaise real life me hum kehte hain – 5 bada hai 3 se → yahi comparison hai.


🗂 List of Comparison Operators

OperatorNameExampleResult
==Equal To (checks value only)5 == "5"true ✅ (value same, type ignored)
===Strict Equal (checks value + type)5 === "5"false ❌ (number ≠ string)
!=Not Equal (value only)10 != "10"false
!==Strict Not Equal (value + type)10 !== "10"true
>Greater Than8 > 5true
<Less Than3 < 5true
>=Greater Than or Equal To7 >= 7true
<=Less Than or Equal To2 <= 5true

✏ Mini Example

let x = 10;
let y = "10";
let z = 5;

console.log(x == y); // true (value same)
console.log(x === y); // false (type different)
console.log(x != y); // false
console.log(x !== y); // true
console.log(x > z); // true
console.log(x <= z); // false

⚠️ Important Difference: == vs ===

OperaTorChecksExampleResult
==Only value5 == "5"true
===Value + Type (Strict)5 === "5"false

💡 Always prefer === and !== for safer comparisons in JavaScript.


💡 Quick Practice

  • Compare "10" and 10 using both == and ===.
  • Check if 15 is greater than or equal to 10.
  • Verify if "A" is less than "a" (hint: Unicode value compare hota hai).
  • Compare two Boolean values using !==.
  • Exercises Set 1
  • Exercises Set 2