Javascript String Compare == sometimes fails

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

    I had the same problem and i noticed that i was comparing two objects

    to solve this issue i had to use

    JSON.stringify(user._id) === JSON.stringify(userId) // true 
    

提交回复
热议问题