Back to articles

Tag archive

#emojis

"πŸ‘©β€πŸ’»πŸŽ‰".length = 7 ??? How to count emojis with Javascript
Nov 14, 2022

"πŸ‘©β€πŸ’»πŸŽ‰".length = 7 ??? How to count emojis with Javascript

Emojis are great, but they can be a pain to work with in JavaScript. The problem is that each emoji is actually made up of multiple UTF-16 code units, so when you try to count the number of emojis in a string, you end up with an incorrect count. I'll explain why the count is wrong, and show you how to get the right number of emoji in a JavaScript string.

Nov 14, 20223 min read1 reactions0 comments