Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 26, 2023 05:45 pm GMT

JS Plays With Emojis!

Do you see the cover image? I saw that in a post, someone wondered about why it happens as if he had suddenly discovered one of Javascript's hidden features. But really happened there?

Let's have some fun with emojis:

const family = ''console.log([...family])// ['', '', '', '', '', '', '']

As you see, we have seven elements in the array, not only the member families; We got some emojis glued together with the zero with joiner character.

console.log(family.includes(''))// do they have a son? returns true!let familyWithTwoDoughters = family.replace('', '')// we get this: 

Happily this is true not only about family emojis, but also for many emojies we may never use. Here is the technologist emoji () that is made of and ! After googling some stuff, I explored this file on Github:
https://github.com/unicode-org/icu/blob/main/icu4c/source/data/unidata/emoji-zwj-sequences.txt
that contains a long list of them.

An Emoji ZWJ Sequence is a combination of multiple emojis which display as a single emoji on supported platforms.

The formula is to combine multiple emojis using the zero width joiner character:
+ ZWJ + =
+ ZWJ + =
+ ZWJ + =

You can play with them in Telegram or any other application that supports them. It is not as magical as some people may think and has nothing to do with JS. We can do all of this using PHP, and any programming language supports strings:

$family = '';var_dump(mb_str_split($family));

Thank you.


Original Link: https://dev.to/webpajooh/js-plays-with-emojis-2poh

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To