This content originally appeared on DEV Community and was authored by Maria Antonella ?
? Today I share with you four ways to convert a string to an array in JavaScript.
const str = 'antonella';
str.split('');
let newStr = [...str];
Array.from(str);
Object.assign([],str);
// ['a ', 'n ', ' t ', 'o ', ' n ', ' e ', ' l', ' l ', ' a ']
? So simple! But they are those things that I google every day because I never remember.?
This content originally appeared on DEV Community and was authored by Maria Antonella ?
Maria Antonella ? | Sciencx (2021-08-18T15:29:09+00:00) 4 ways to convert a string to an array in Javascript. Retrieved from https://www.scien.cx/2021/08/18/4-ways-to-convert-a-string-to-an-array-in-javascript/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.