admin管理员组文章数量:1323735
In the javascript console of google chrome type the following code:
"i" == "i̇"
and realize that it returns false. But both of them has the same char code (105).
How and why this is possible?
After ments, I realize second i has 2 characters, but second character was made from the following code:
"İ".toLowerCase() // outputs i̇
also
"İ".length // returns 1
How and why javascript .toLowerCase() can count up the char length?
In the javascript console of google chrome type the following code:
"i" == "i̇"
and realize that it returns false. But both of them has the same char code (105).
How and why this is possible?
After ments, I realize second i has 2 characters, but second character was made from the following code:
"İ".toLowerCase() // outputs i̇
also
"İ".length // returns 1
How and why javascript .toLowerCase() can count up the char length?
Share Improve this question edited Sep 23, 2014 at 12:52 Orhun Alp Oral asked Sep 23, 2014 at 12:44 Orhun Alp OralOrhun Alp Oral 7541 gold badge7 silver badges15 bronze badges 7- 4 The second "i" isn't really an "i". – Pointy Commented Sep 23, 2014 at 12:45
- Just copy/paste the following code I wrote and see. – Orhun Alp Oral Commented Sep 23, 2014 at 12:45
- 1 There's an extra character after the "i" in the second string. – Pointy Commented Sep 23, 2014 at 12:47
- @fauverism well you're right in a way, but both parison operands are actually strings in this case. – Pointy Commented Sep 23, 2014 at 12:49
- 1 @fauverism has nothing to do with that in this case.... – epascarello Commented Sep 23, 2014 at 12:49
2 Answers
Reset to default 9console.log("i".length, "i̇".length)
> 1 2
The second string has an extra character. The result is false
as the two strings are not the same.
If we use charCodeAt()
we can see that this extra character is Unciode symbol 775, known as a bining dot above.
̇
bining dot above
01407
775
0x307
̇
The right-hand string has two characters: an i
and a "bining tilde" following that. You can tell just by looking closely at the title of your question!
本文标签: javascriptWhy quotiquot is not equals to quoti̇quotStack Overflow
版权声明:本文标题:javascript - Why "i" is not equals to "i̇"? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742119098a2421611.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论