两个相同的字符串不相等

时间:2018-12-20 16:41:34

标签: javascript

我有2个相等的字符串,并且在执行console.log()以了解它们是否相等时,我这样做:

console.log("message = " + document.getElementsByClassName("hud-chat-message")[i].childNodes[0].innerHTML + " type = " + typeof document.getElementsByClassName("hud-chat-message")[i].childNodes[0].innerHTML)
            console.log("chatbotname = " + Ultimate.bots[name].chatBotName + " type = " + typeof Ultimate.bots[name].chatBotName)
            console.log(document.getElementsByClassName("hud-chat-message")[i].childNodes[0].innerHTML == Ultimate.bots[name].chatBotName)

然后它说:

message = <strong>Leaderboard on Discord</strong><small> (leaderboard!)</small><span class="botTagRegular botTag bot">BOT</span> type = string
VM3681:229 chatbotname = <strong>Leaderboard on Discord</strong><small> (leaderboard!)</small><span class='botTagRegular botTag bot'>BOT</span> type = string
VM3681:230 false

两个字符串具有相同的类型并且相等,但是它表示false,它不等于...为什么?怎么了? 谢谢

1 个答案:

答案 0 :(得分:1)

字符串<span class="botTagRegular botTag bot">不等于<span class='botTagRegular botTag bot'>,因为'"是不同的符号