DEV Community

loading...
Cover image for How to Turn a String into an Array of Characters: 3 Ways to do so.

How to Turn a String into an Array of Characters: 3 Ways to do so.

islam profile image Islam Sayed ・1 min read

Here are 3 different ways to convert a string into an array of its characters in javascript.

const str = 'Hello';

//1. Using split() method
const arr1 = str.split('');

//2. Using spread operator
const arr2 = [...str];

//3. Using Array.from() method
const arr3 = Array.from(str);
Enter fullscreen mode Exit fullscreen mode

Follow me on:
👉Instagram: https://www.instagram.com/islamcodehood
👉Twitter: https://twitter.com/islam_sayed8
👉Facebook page: https://www.facebook.com/Codehood-111...
👉Dev: https://dev.to/islam

Discussion (3)

pic
Editor guide
Collapse
eth2234 profile image
Collapse
hseritt profile image
Harlin Seritt

:-D yes, indeed.