所以我正在使用 socket.io 开发一个聊天应用程序,我想确定它是我的消息还是其他人的消息。我为此使用的两件事是我从本地存储中检索的全名和当我发送新消息时从服务器返回的全名。有人知道为什么即使它们都是字符串并且它们都由相同的单词组成,为什么它们仍然不一样吗?
isItMyMsg(message){
console.log(localStorage.getItem('fullName'));
console.log(message.fullname);
console.log(localStorage.getItem('fullName') === message.fullName);
return localStorage.getItem('fullName') === message.fullName
}
这是我拍摄的记录结果的屏幕截图。两个是本地存储和服务器对象的结果,错误是我评估它们是否相同时的结果。我期待它返回 TRUE,但我得到了 FALSE