最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why "i" is not equals to "i̇"? - Stack Overflow

programmeradmin1浏览0评论

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
 |  Show 2 more ments

2 Answers 2

Reset to default 9
console.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!

发布评论

评论列表(0)

  1. 暂无评论