谁能解释这里发生了什么?两个相等的字符串 return 比较时为 false
Can anyone explain whats going on here? Two equal strings return false when compared
var numberA = "+6281237627470"; var numberB = "+6281237627470";
console.log(numberA == numberB);
==> false
这是link到fiddle
数字末尾有ascii值为8236的隐藏字符
您可以通过
验证它们
console.log(numberA.length, numberB.length) // 14, 16
console.log(numberA.split("").map(char => console.log(char.charCodeAt(0))))
console.log(numberB.split("").map(char => console.log(char.charCodeAt(0)))) // this will give two 8236 ascii value at the last of the string
var numberA = "+6281237627470"; var numberB = "+6281237627470";
console.log(numberA == numberB);
==> false
这是link到fiddle
数字末尾有ascii值为8236的隐藏字符 您可以通过
验证它们console.log(numberA.length, numberB.length) // 14, 16
console.log(numberA.split("").map(char => console.log(char.charCodeAt(0))))
console.log(numberB.split("").map(char => console.log(char.charCodeAt(0)))) // this will give two 8236 ascii value at the last of the string