Home > front end >  Is there still no easy way to split strings with compound emojis into an array?
Is there still no easy way to split strings with compound emojis into an array?

Time:12-31

There are many good (and bad) ways to split a string into an array in JavaScript.

E.g. in ES6 by just using the spread operator:

let str = "example 1";
let arr = [...str];
console.log(arr); 
// ['e', 'x', 'a', 'm', 'p', 'l', 'e', ' ', '1']

A lot of them still work when there is an emoji included

let str = "example 2            
  • Related