Javascript String Compare == sometimes fails

后端 未结 9 2038
你的背包
你的背包 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 17:58

    Java servlet may send strings i.e.

    out.println("CARD_VALID");

    or

    out.print("CARD_VALID");

    These may look identical in Javascript, but there are white spaces at the end in the first case.

提交回复
热议问题