String To Array In One Line : JavaScript
shivamkapasia0
Posted on October 31, 2021
Hey folks!
we can easily convert String into an array by using spread operator (...)
:
const string = 'Shivam Kapasia';
const array = [...string];
console.log(`${array}`); // S,h,i,v,a,m, ,K,a,p,a,s,i,a
Note : The array will also include space, but if you don't want to store space in array first remove space from string then use spread operator.
What’s your preferred way to convert string into an array ?
💖 💪 🙅 🚩
shivamkapasia0
Posted on October 31, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
javascript How Technology is Revolutionizing Fashion: Embracing Digital Tools at Braniff Boutique
October 20, 2024