Fun with JavaScript and Emoji


Today Wes Bos tweeted a few fun things one can do with JavaScript and Emoji:

  1. It’s possible to spread emoji units (or how are they called?) into their single parts:

    // ["πŸ‘¨", "‍", "πŸ‘©", "‍", "πŸ‘§", "‍", "πŸ‘¦"]
  2. Combining Emoji is also possible:

    ["πŸ‘¨", "‍", "πŸ‘©", "‍", "πŸ‘§"].reduce((prev, curr) => prev + curr)
    // "πŸ‘¨β€πŸ‘©β€πŸ‘§"
  3. And oh, you can even replace single emoji within emoji units, yielding a new emoji unit:

    'πŸ‘©β€πŸ‘©β€πŸ‘¦'.replace(/πŸ‘©/g, 'πŸ‘¨')
    // "πŸ‘¨β€πŸ‘¨β€πŸ‘¦"
  4. This kind of sorcery also works with skin tone modifiers by the way:

    // ["πŸ›€", "🏾"]
    ["πŸ›€", "🏾"].reduce((prev, curr) => prev + curr)
    // "πŸ›€πŸΎ"
    'πŸ›€πŸΎ'.replace("🏾", "")
    // "πŸ›€"

Geekfun! 🌈

Elsewhere ,

2 Responses to Fun with JavaScript and Emoji

  1. Pingback: Fun with JavaScript and emoji -

  2. Pingback: runes – Unicode-aware JS string splitting with full Emoji support |

Leave a Reply

Your email address will not be published. Required fields are marked *