Search code examples
javascriptunicodeemoji

Finding Emoji combinations programmatically, is reversing the Spread Operator possible?


There are a number of emojis that are not just stand-alone Unicode characters. They are actually a combination of two or more other emojis. e.g.

console.log([...'๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ง']); // ๐Ÿ‘จ + ๐Ÿ‘จ+ ๐Ÿ‘ง+ ๐Ÿ‘ง

console.log([...'๐Ÿง‘๐Ÿฟโ€โค๏ธโ€๐Ÿ’‹โ€๐Ÿง‘๐Ÿพ']); // ๐Ÿง‘ + โค + ๐Ÿ’‹ + ๐Ÿง‘

console.log([...'๐Ÿง‘โ€๐Ÿš€']); // ๐Ÿง‘ + ๐Ÿš€

What I would like to know, is given the constituent parts, is it possible to go the other way and combine emojis so that you can generate the combined symbol? Really the opposite of what the Spread Operator is doing here.

e.g. Is it possible to generate ๐Ÿ‘จโ€๐Ÿ‘จโ€๐Ÿ‘งโ€๐Ÿ‘ง from ๐Ÿ‘จ,๐Ÿ‘จ,๐Ÿ‘ง,๐Ÿ‘ง

I've tried I few different ideas but nothing seems to work - mainly just getting SyntaxErrors.


Solution

  • First link in the google https://www.bram.us/2016/08/27/fun-with-javascript-and-emoji/

    ["๐Ÿ‘จ", "โ€", "๐Ÿ‘จ", "โ€", "๐Ÿ‘ง", "โ€", "๐Ÿ‘ง"].reduce((prev, next) => prev + next)
    

    It is really easy to achieve