Poetry with complex emoji

Posted 2 years ago
Return to overview

Let's take one of my favourite emoji, the "male programmer": ๐Ÿ‘จโ€๐Ÿ’ป. If you'd describe this, you could say something like: "It's a man behind a laptop". So what does JavaScript do?

When an emoji is a 'complex' emoji, it's being joined by a zero width joiner character (`u200D`), so you can basically split the emoji String like so:

'๐Ÿ‘จโ€๐Ÿ’ป'.split('\u200D') // output: ["๐Ÿ‘จ", "๐Ÿ’ป"]

Or, when you're into magic, just use the spread operator:

[...'๐Ÿ‘จโ€๐Ÿ’ป'] // output: ["๐Ÿ‘จ", "๐Ÿ’ป"]

Pretty neat huh?

Well, it gets better, because the opposite is also possible, by joining multiple "simple" emoji into a "complex" emoji. Again, we use the zero width joiner:

["๐Ÿ‘จ", "๐Ÿ’ป"].join('\u200D') // output: ๐Ÿ‘จโ€๐Ÿ’ป

It's pretty useless knowledge, but interesting stuff! For the full list of "complex" emoji, please take a look at this unicode chart.

As you can see, these are just all little stories which I think is super neat!

A couple of examples:

'โค๏ธโ€๐Ÿ”ฅ'.split('\u200D') // output: ["โค","๐Ÿ”ฅ"]

'๐Ÿซฑ๐Ÿผโ€๐Ÿซฒ๐Ÿฝ'.split('\u200D') // output: ["๐Ÿซฑ", "๐Ÿผ", "๐Ÿซฒ", "๐Ÿฝ"]

'๐Ÿง‘๐Ÿฝโ€๐Ÿซ'.split('\u200D') // output: ["๐Ÿง‘", "๐Ÿฝ", "โ€", "๐Ÿซ"]

'๐Ÿ‘จโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ'.split('\u200D') // output: ["๐Ÿง‘", "๐Ÿ‘จ", "โ€", "๐Ÿ‘ฉ", "โ€", "๐Ÿ‘ง", "โ€", "๐Ÿ‘ฆ"]

Return to overview