How can I get a character array from a string?

Note: This is not unicode compliant. "I💖U".split('') results in the
4 character array ["I", "�", "�", "u"] which can lead to dangerous
bugs. See answers below for safe alternatives.

Just split it by an empty string.

var output = "Hello world!".split('');
console.log(output);

See the String.prototype.split() MDN docs.

Leave a Comment