But the equal operator == is less strict than the identical operator === and can have some hard to predict results, so it’s typically better to only use the identical operator.

Strings

When comparing a string to an integer the string is evaluated as 0!!

  if ("ABC" == 0)

evaluates true because first “ABC” is converted to integer and becomes 0 then it is compared to 0.

Use === if you are comparing non strings to a string value

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.

Comments

Your email address will not be published. Required fields are marked *