🤣 😂
Emojis in code? Why not?
Explanation
- First of all, emojis are different to normal text. Emojis UTF-16 encoding is greater than 16 bits, so
"😀".length
will return 2 (and"😀".split('')
will return 2 symbols). - In the code above we just get codes of first emojis symbols (55358 and 55357).
PS. codePointAt
method is preferable for handling emojis (instead of charCodeAt
).