Friday Quiz or Emoji are weird in JavaScript
Can you guess, what will be the output 'π©βπ©βπ§βπ§'.length // ??
It is 11.
What about this one: ['βΊ', 'π', '1οΈβ£', 'π¦π¨', 'π±ββοΈ', 'π©ββ€οΈβπ¨', 'π©βπ©βπ§βπ§'].map((emoji) => emoji.length)?
Well, here it goes: [1, 2, 3, 4, 5, 8, 11].
My favorite two examples look like marriage and divorce:
['π¨', 'β', 'π©'].reduce((cur, next) => cur += next) // π¨βπ©
[...'π¨βπ©βπ§'] // ['π¨', 'β', 'π©', 'β', 'π§']
Iβve group every emoji by its length, so you donβt have to https://github.com/FSou1/EmojiGroupedByLength.
Happy Friday.
More theory: https://gomakethings.com/emoji-are-still-weird-but-modern-browser-methods-help/