How can I split a string containing emoji into an array?

JavaScript ES6 has a solution!, for a real split:

[..."😴😄😃⛔🎠🚓🚇"] // ["😴", "😄", "😃", "⛔", "🎠", "🚓", "🚇"]

Yay? Except for the fact that when you run this through your transpiler, it might not work (see @brainkim’s comment). It only works when natively run on an ES6-compliant browser. Luckily this encompasses most browsers (Safari, Chrome, FF), but if you’re looking for high browser compatibility this is not the solution for you.

Leave a Comment