Javascript String Compare == sometimes fails

后端 未结 9 2045
你的背包
你的背包 2020-12-05 17:25

How could the following code sometimes evaluate to false?

(transport.responseText == \'1\' || 
 transport.responseText == \'CARD_VALID\')

M

9条回答
  •  再見小時候
    2020-12-05 18:15

    Try using === to match exactly (type and value). This is the recommended comparison operator in javascript.

    Check the datatypes of the strings to make sure, and look for hidden unicode or control characters in both strings.

提交回复
热议问题