Programming Languages
JavaScript
Subjective
Sep 18, 2025
Explain the difference between loose equality (==) and strict equality (===) in JavaScript.
Detailed Explanation
== (loose equality): Compares values after type coercion
=== (strict equality): Compares values without type coercion
Examples:
"5" == 5 // true (string converted to number)
"5" === 5 // false (different types)
null == undefined // true
null === undefined // false
0 == false // true
0 === false // false
Best practice: Always use === unless you specifically need type coercion.
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts