Programming Languages JavaScript Subjective
Sep 25, 2025

What is the difference between == and === operators?

Detailed Explanation

== (Loose Equality):
- Performs type coercion before comparison
- Converts operands to same type, then compares

=== (Strict Equality):
- No type coercion
- Compares both value and type

Examples:


5 == "5" // true (string converted to number)
5 === "5" // false (different types)

true == 1 // true (boolean converted to number)
true === 1 // false (different types)

null == undefined // true (special case)
null === undefined // false (different types)

0 == false // true (both convert to 0)
0 === false // false (different types)

Best practice: Use === for predictable comparisons.

Discussion (0)

No comments yet. Be the first to share your thoughts!

Share Your Thoughts
Feedback