Are there any cases where
x == y //false
x === y //true
is that ever possible in JS? :)
Are there any cases where
x == y //false
x === y //true
is that ever possible in JS? :)
No. That's never possible. === checks for type and equality. == just checks for equality. If something isn't == it can never be ===.
It'd be impossible. == compares value, while === compares value and type. Your case would require an impossible condition.
a === b -> (typeof(a) == typeof(b)) && (value(a) == value(b))
a == b -> (value(a) == value(b))
You couldn't have the value comparisons in the == case be true while requiring the exact same comparison in === become false.
== - Returns true if the operands are equal.
=== - Returns true if the operands are equal and of the same type.
So, I'll say not possible.
Briefly, if === is true, then == will return true. If === returns false, then == may or may not return false.
Examples:
5===5 is true, which means that 5==5 also must be true.
'5'===5 is false, and '5'==5 is true.
'6'===5 is false, and '6'==5 is also false.
This behavior is because a===b checks to make sure that the value and type of a and b are equal, while a==b only checks to make sure that their values are equal.