Sometimes, we want to split a string into an array of characters with JavaScript
In this article, we’ll look at how to split a string into an array of characters with JavaScript.
How to split a string into an array of characters with JavaScript?
To split a string into an array of characters with JavaScript, we use the spread operator.
For instance, we write
const arr = [...str];
to spread the characters of the str
string into an array.
This works properly with all Unicode characters.
Conclusion
To split a string into an array of characters with JavaScript, we use the spread operator.