how to make a string to arry javascript code example

Example 1: string to array javascript

const str = 'Hello!';

console.log(Array.from(str)); //  ["H", "e", "l", "l", "o", "!"]

Example 2: js string to array

str = 'How are you doing today?';
console.log(str.split(' '));

>> (5) ["How", "are", "you", "doing", "today?"]

Example 3: js string to array

var myString = 'no,u';
var MyArray = myString.split(',');//splits the text up in chunks

Example 4: convert string to array javascript

let myArray = str.split(" ");

Tags:

Java Example