+ 2
Why is javascript like this? alert(1=="1")--> true alert(1=="hello")--> true alert("1"=="hello")--> false
Please click like button
3 Respostas
+ 1
Ferry,
I highly suggest you visit this MDN page, it will give you a better/deeper understanding of loose and strict equality.
Reference https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness
(==) - Abstract Equality Comparison ("loose equality", "double equals"), will perform a type conversion when comparing two things.
Loose equality compares two values for equality, after converting both values to a common type.
(===) - Strict Equality Comparison ("strict equality", "identity", "triple equals"),
will do the same comparison as double equals, but without type conversion.
Strict equality compares two values for equality. Neither value is implicitly converted. If the values have different types, the values are considered unequal.
+ 1
ODLNT
Thank you very much
0
That is crazy!??