What is the difference with == and === in JS?



=== and == are both comparison operators, but they have a slight difference.

=== is used to compare both type and value. So if you tried 5==="5", for example, it would return false because even though the values are the same the types (integer and string) are different.

== on the other hand, compares value and ignores type. Therefore, 5=="5" would return true even though there is a type mismatch (integer and string).


I just attempted to use
if ("the birds are high"length === 18)
as well as every other possible combination of the two types and two comparison operators. they all came out to be true. what is up with that?


In your example there, .length gets an integer value which is compared to another integer which will result in true either way (assuming the length matches the value that it is being compared to). Also I was using string and integer as an example, other value types may apply as well. Can you elaborate on your problem a little?