DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 970,177 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for How to Turn a String into an Array of Characters: 3 Ways to do so.
Islam Sayed
Islam Sayed

Posted on

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

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

Top comments (3)

Collapse
 
eth2234 profile image
Ebrahim Hasan

omg haha

Collapse
 
hseritt profile image
Harlin Seritt

:-D yes, indeed.

Visualizing Promises and Async/Await 🀯

async await

☝️ Check out this all-time classic DEV post