+ 2
Comparison operators: what does '===' and '!==' mean? Explain plz
3 Answers
+ 1
=== and !== check types of compared variables and their values.
For example let's check comparision of number and string:
9 !== "9"
But
9 == "9"
Types are different here.
0
== is used to check values are equal or not
example
8==8 returns true & 8==7 will return false
!= this means not equal to, just opposite of ==
example
8!=8 will return false here but 8!=7 returns true
0
I don't understand why in JS if you compare a string and a float with the simple equal operator (==) you get true if one is String and the other not. Therefore, we have to use identical operator to get the real comparison string===float, false honey.