Poetry with complex emoji
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: ["๐ง", "๐จ", "โ", "๐ฉ", "โ", "๐ง", "โ", "๐ฆ"]